- got built in memory leak working. Just edit leak_dumper.h and uncomment:

//#define SL_LEAK_DUMP
- got better / more accurate stack dumps when we detect errors in game.
- Both of these need to be worked on in windows next, win32 may not compile for now until i fix it on that platform.
- BE VERY CAREFUL when working in leak_dumper.* it may cause GCC and your system to crash if you don't know what you are doing!
This commit is contained in:
Mark Vejvoda 2012-04-14 21:21:09 +00:00
parent ed201fa5d3
commit 8c0bf75bf5
117 changed files with 1760 additions and 1071 deletions

View File

@ -83,6 +83,7 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER)
${GLEST_LIB_INCLUDE_ROOT}map
${GLEST_LIB_INCLUDE_ROOT}sound
${GLEST_LIB_INCLUDE_ROOT}xml
${GLEST_LIB_INCLUDE_ROOT}xml/rapidxml
${GLEST_MAIN_INCLUDE_ROOT}facilities
${GLEST_MAIN_INCLUDE_ROOT}graphics
${GLEST_MAIN_INCLUDE_ROOT}game

View File

@ -144,7 +144,7 @@ void Renderer::checkGlCaps() {
message += "MegaGlest needs at least version 1.3 to work\n";
message += "You may solve this problem by installing your latest video card drivers";
throw runtime_error(message.c_str());
throw megaglest_runtime_error(message.c_str());
}
//opengl 1.4 or extension
@ -157,7 +157,7 @@ void Renderer::checkGlCaps() {
void Renderer::checkExtension(const string &extension, const string &msg) {
if(isGlExtensionSupported(extension.c_str()) == false) {
string str= "OpenGL extension not supported: " + extension + ", required for " + msg;
throw runtime_error(str);
throw megaglest_runtime_error(str);
}
}

View File

@ -124,6 +124,7 @@ IF(BUILD_MEGAGLEST)
${GLEST_LIB_INCLUDE_ROOT}sound
${GLEST_LIB_INCLUDE_ROOT}sound/openal
${GLEST_LIB_INCLUDE_ROOT}xml
${GLEST_LIB_INCLUDE_ROOT}xml/rapidxml
${GLEST_LIB_INCLUDE_ROOT}glew
${GLEST_LIB_INCLUDE_ROOT}lua
${GLEST_LIB_INCLUDE_ROOT}map)

View File

@ -376,7 +376,7 @@ void Ai::update() {
for(int ruleIdx = 0; ruleIdx < aiRules.size(); ++ruleIdx) {
AiRule *rule = aiRules[ruleIdx];
if(rule == NULL) {
throw runtime_error("rule == NULL");
throw megaglest_runtime_error("rule == NULL");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [ruleIdx = %d]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),ruleIdx);

View File

@ -71,7 +71,7 @@ AiInterface::AiInterface(Game &game, int factionIndex, int teamIndex, int useSta
fp = fopen(aiLogFile.c_str(), "wt");
#endif
if(fp == NULL) {
throw runtime_error("Can't open file: [" + aiLogFile + "]");
throw megaglest_runtime_error("Can't open file: [" + aiLogFile + "]");
}
fprintf(fp, "MegaGlest AI log file for Tech [%s] Faction [%s] #%d\n\n",this->gameSettings->getTech().c_str(),this->world->getFaction(this->factionIndex)->getType()->getName().c_str(),this->factionIndex);
}
@ -159,18 +159,18 @@ CommandResult AiInterface::giveCommand(const Unit *unit, const CommandType *comm
if(unit == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unit in AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const UnitType* unitType= unit->getType();
if(unitType == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unittype with unit id: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unit->getId(),factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(commandType == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] commandType == NULL, unit id: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unit->getId(),factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const CommandType* ct= unit->getType()->findCommandTypeById(commandType->getId());
if(ct == NULL) {
@ -184,7 +184,7 @@ CommandResult AiInterface::giveCommand(const Unit *unit, const CommandType *comm
std::string worldLog = world->DumpWorldToLog();
std::string sError = "worldLog = " + worldLog + " " + string(szBuf);
throw runtime_error(sError);
throw megaglest_runtime_error(sError);
}
if(executeCommandOverNetwork() == true) {
@ -213,13 +213,13 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
if(unit == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unit with index: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unitIndex,factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const UnitType* unitType= unit->getType();
if(unitType == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unittype with unit index: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unitIndex,factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const CommandType* ct= unit->getType()->findCommandTypeById(commandType->getId());
if(ct == NULL) {
@ -233,7 +233,7 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
std::string worldLog = world->DumpWorldToLog();
std::string sError = "worldLog = " + worldLog + " " + string(szBuf);
throw runtime_error(sError);
throw megaglest_runtime_error(sError);
}
if(executeCommandOverNetwork() == true) {
@ -260,13 +260,13 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
if(unit == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unit with index: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unitIndex,factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const UnitType* unitType= unit->getType();
if(unitType == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unittype with unit index: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unitIndex,factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const CommandType* ct= unit->getType()->findCommandTypeById(commandType->getId());
if(ct == NULL) {
@ -280,7 +280,7 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
std::string worldLog = world->DumpWorldToLog();
std::string sError = "worldLog = " + worldLog + " " + string(szBuf);
throw runtime_error(sError);
throw megaglest_runtime_error(sError);
}
if(executeCommandOverNetwork() == true) {
@ -307,13 +307,13 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
if(unit == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unit with index: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unitIndex,factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const UnitType* unitType= unit->getType();
if(unitType == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] Can not find AI unittype with unit index: %d, AI factionIndex = %d. Game out of synch.",__FILE__,__FUNCTION__,__LINE__,unitIndex,factionIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const CommandType* ct= (commandType != NULL ? unit->getType()->findCommandTypeById(commandType->getId()) : NULL);
if(ct == NULL) {
@ -327,7 +327,7 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
std::string worldLog = world->DumpWorldToLog();
std::string sError = "worldLog = " + worldLog + " " + string(szBuf);
throw runtime_error(sError);
throw megaglest_runtime_error(sError);
}
if(executeCommandOverNetwork() == true) {
@ -401,7 +401,7 @@ Unit *AiInterface::getMyUnitPtr(int unitIndex) {
if(unitIndex >= world->getFaction(factionIndex)->getUnitCount()) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] unitIndex >= world->getFaction(factionIndex)->getUnitCount(), unitIndex = %d, world->getFaction(factionIndex)->getUnitCount() = %d",__FILE__,__FUNCTION__,__LINE__,unitIndex,world->getFaction(factionIndex)->getUnitCount());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return world->getFaction(factionIndex)->getUnit(unitIndex);

View File

@ -922,7 +922,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
char szBuf[1024]="";
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,producers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const Unit *unit = aiInterface->getMyUnit(currentProducerIndex);
@ -954,13 +954,13 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
char szBuf[1024]="";
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,producers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(prIndex >= producers.size()) {
char szBuf[1024]="";
printf("In [%s::%s Line: %d] prIndex >= producers.size(), currentProducerIndex = %d, i = %d,producers.size() = %lu \n",__FILE__,__FUNCTION__,__LINE__,prIndex,i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= producers.size(), currentProducerIndex = %d, i = %d,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,i,(unsigned long)producers.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
currentCommandCount=aiInterface->getMyUnit(currentProducerIndex)->getCommandSize();
@ -1020,13 +1020,13 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
char szBuf[1024]="";
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,backupProducers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)backupProducers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,backupProducers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)backupProducers.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(prIndex >= backupProducers.size()) {
char szBuf[1024]="";
printf("In [%s::%s Line: %d] prIndex >= backupProducers.size(), currentProducerIndex = %d, i = %d,backupProducers.size() = %lu \n",__FILE__,__FUNCTION__,__LINE__,prIndex,i,(unsigned long)backupProducers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= backupProducers.size(), currentProducerIndex = %d, i = %d,backupProducers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,i,(unsigned long)backupProducers.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
currentCommandCount=aiInterface->getMyUnit(currentProducerIndex)->getCommandSize();

View File

@ -50,7 +50,7 @@ struct CellMetrics {
//case Field::ANY_WATER: return field2;
//case Field::DEEP_WATER: return field3;
//case Field::AMPHIBIOUS: return field4;
default: throw runtime_error("Unknown Field passed to CellMetrics::get()");
default: throw megaglest_runtime_error("Unknown Field passed to CellMetrics::get()");
}
}
@ -61,7 +61,7 @@ struct CellMetrics {
//case Field::ANY_WATER: field2 = val; return;
//case Field::DEEP_WATER: field3 = val; return;
//case Field::AMPHIBIOUS: field4 = val; return;
default: throw runtime_error("Unknown Field passed to CellMetrics::set()");
default: throw megaglest_runtime_error("Unknown Field passed to CellMetrics::set()");
}
}

View File

@ -72,7 +72,7 @@ ClusterMap::~ClusterMap() {
assert(Edge::NumEdges(Field(f)) == 0);
assert(Transition::NumTransitions(Field(f)) == 0);
if (Edge::NumEdges(Field(f)) != 0 || Transition::NumTransitions(Field(f)) != 0) {
throw runtime_error("memory leak");
throw megaglest_runtime_error("memory leak");
}
}
}

View File

@ -147,7 +147,7 @@ public:
}
}
if (it == t->edges.end()) {
throw runtime_error("bad connection in ClusterMap.");
throw megaglest_runtime_error("bad connection in ClusterMap.");
}
if ((*it)->maxClear() >= size) {
return (*it)->cost(size);
@ -221,7 +221,7 @@ public:
case CardinalDir::WEST:
return getWestBorder(cluster);
default:
throw runtime_error("ClusterMap::getBorder() passed dodgey direction");
throw megaglest_runtime_error("ClusterMap::getBorder() passed dodgey direction");
}
return 0; // keep compiler quiet
}

View File

@ -107,7 +107,7 @@ void PathFinder::removeUnitPrecache(Unit *unit) {
TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStuck, int frameIndex) {
if(map == NULL) {
throw runtime_error("map == NULL");
throw megaglest_runtime_error("map == NULL");
}
if(frameIndex >= 0) {
@ -184,7 +184,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
}
}
else {
throw runtime_error("unsupported or missing path finder detected!");
throw megaglest_runtime_error("unsupported or missing path finder detected!");
}
}
@ -399,7 +399,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
}
}
else {
throw runtime_error("unsupported or missing path finder detected!");
throw megaglest_runtime_error("unsupported or missing path finder detected!");
}
}
break;
@ -801,7 +801,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
if(map == NULL) {
throw runtime_error("map == NULL");
throw megaglest_runtime_error("map == NULL");
}
const bool showConsoleDebugInfo = Config::getInstance().getBool("EnablePathfinderDistanceOutput","false");
@ -830,7 +830,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
for(int i=0; i < factions[unitFactionIndex].precachedPath[unit->getId()].size(); i++) {
Vec2i nodePos = factions[unitFactionIndex].precachedPath[unit->getId()][i];
if(map->isInside(nodePos) == false || map->isInsideSurface(map->toSurfCoords(nodePos)) == false) {
throw runtime_error("Pathfinder invalid node path position = " + nodePos.getString() + " i = " + intToStr(i));
throw megaglest_runtime_error("Pathfinder invalid node path position = " + nodePos.getString() + " i = " + intToStr(i));
}
if(i < pathFindRefresh ||
@ -855,7 +855,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
for(int i=0; i < factions[unitFactionIndex].precachedPath[unit->getId()].size(); i++) {
Vec2i nodePos = factions[unitFactionIndex].precachedPath[unit->getId()][i];
if(map->isInside(nodePos) == false || map->isInsideSurface(map->toSurfCoords(nodePos)) == false) {
throw runtime_error("Pathfinder invalid node path position = " + nodePos.getString() + " i = " + intToStr(i));
throw megaglest_runtime_error("Pathfinder invalid node path position = " + nodePos.getString() + " i = " + intToStr(i));
}
if(i < pathFindRefresh ||
@ -930,7 +930,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
int pathCount=0;
for(int k=i+1; k <= j; k++) {
if(k >= cachedPath.size()) {
throw runtime_error("k >= cachedPath.size() k = " + intToStr(k) + " cachedPath.size() = " + intToStr(cachedPath.size()));
throw megaglest_runtime_error("k >= cachedPath.size() k = " + intToStr(k) + " cachedPath.size() = " + intToStr(cachedPath.size()));
}
if(frameIndex >= 0) {
@ -985,7 +985,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
int pathCount=0;
for(int k=i+1; k < cachedPath.size(); k++) {
if(k >= cachedPath.size()) {
throw runtime_error("#2 k >= cachedPath.size() k = " + intToStr(k) + " cachedPath.size() = " + intToStr(cachedPath.size()));
throw megaglest_runtime_error("#2 k >= cachedPath.size() k = " + intToStr(k) + " cachedPath.size() = " + intToStr(cachedPath.size()));
}
if(frameIndex >= 0) {
@ -1044,7 +1044,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
Node *firstNode= newNode(factions[unitFactionIndex],maxNodeCount);
assert(firstNode != NULL);
if(firstNode == NULL) {
throw runtime_error("firstNode == NULL");
throw megaglest_runtime_error("firstNode == NULL");
}
firstNode->next= NULL;
@ -1341,7 +1341,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
for(int i=0; currNode->next != NULL; currNode= currNode->next, i++) {
Vec2i nodePos = currNode->next->pos;
if(map->isInside(nodePos) == false || map->isInsideSurface(map->toSurfCoords(nodePos)) == false) {
throw runtime_error("Pathfinder invalid node path position = " + nodePos.getString() + " i = " + intToStr(i));
throw megaglest_runtime_error("Pathfinder invalid node path position = " + nodePos.getString() + " i = " + intToStr(i));
}
//printf("nodePos [%s]\n",nodePos.getString().c_str());
@ -1452,7 +1452,7 @@ void PathFinder::processNearestFreePos(const Vec2i &finalPos, int i, int j, int
Vec2i PathFinder::computeNearestFreePos(const Unit *unit, const Vec2i &finalPos) {
if(map == NULL) {
throw runtime_error("map == NULL");
throw megaglest_runtime_error("map == NULL");
}
//unit data
@ -1485,7 +1485,7 @@ float PathFinder::heuristic(const Vec2i &pos, const Vec2i &finalPos) {
PathFinder::Node * PathFinder::minHeuristicFastLookup(FactionState &faction) {
assert(faction.openNodesList.empty() == false);
if(faction.openNodesList.empty() == true) {
throw runtime_error("openNodesList.empty() == true");
throw megaglest_runtime_error("openNodesList.empty() == true");
}
Node *result = faction.openNodesList.begin()->second[0];

View File

@ -452,7 +452,7 @@ bool RoutePlanner::refinePath(Unit *unit) {
UnitPathInterface *unitpath = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(unitpath);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
UnitPath &path = *advPath;
@ -494,7 +494,7 @@ void RoutePlanner::smoothPath(Unit *unit) {
UnitPathInterface *path = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(path);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
if (advPath->size() < 3) {
@ -571,7 +571,7 @@ TravelState RoutePlanner::doRouteCache(Unit *unit) {
UnitPathInterface *unitpath = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(unitpath);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
UnitPath &path = *advPath;
@ -632,7 +632,7 @@ TravelState RoutePlanner::doQuickPathSearch(Unit *unit, const Vec2i &target) {
UnitPathInterface *unitpath = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(unitpath);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
UnitPath &path = *advPath;
@ -671,7 +671,7 @@ TravelState RoutePlanner::findAerialPath(Unit *unit, const Vec2i &targetPos) {
UnitPathInterface *unitpath = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(unitpath);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
UnitPath &path = *advPath;
@ -721,7 +721,7 @@ TravelState RoutePlanner::findPathToLocation(Unit *unit, const Vec2i &finalPos)
UnitPathInterface *unitpath = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(unitpath);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
UnitPath &path = *advPath;
@ -847,7 +847,7 @@ TravelState RoutePlanner::customGoalSearch(PMap1Goal &goal, Unit *unit, const Ve
UnitPathInterface *unitpath = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(unitpath);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
UnitPath &path = *advPath;
@ -889,7 +889,7 @@ TravelState RoutePlanner::findPathToGoal(Unit *unit, PMap1Goal &goal, const Vec2
UnitPathInterface *unitpath = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(unitpath);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
UnitPath &path = *advPath;
@ -992,7 +992,7 @@ bool RoutePlanner::repairPath(Unit *unit) {
UnitPathInterface *unitpath = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(unitpath);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
UnitPath &path = *advPath;
@ -1084,7 +1084,7 @@ TravelState RoutePlanner::doFullLowLevelAStar(Unit *unit, const Vec2i &dest) {
return tsImpossible;
default:
throw runtime_error("Something that shouldn't have happened, did happen :(");
throw megaglest_runtime_error("Something that shouldn't have happened, did happen :(");
}
if (path.empty()) {
unit->setCurrSkill(scStop);

View File

@ -190,7 +190,7 @@ private:
UnitPathInterface *path = unit->getPath();
UnitPath *advPath = dynamic_cast<UnitPath *>(path);
if(advPath == NULL) {
throw runtime_error("Invalid or NULL unit path pointer!");
throw megaglest_runtime_error("Invalid or NULL unit path pointer!");
}
assert(advPath->isEmpty() == false);

View File

@ -64,7 +64,7 @@ void AutoTest::updateNewGame(Program *program, MainMenu *mainMenu) {
loadGameSettingsFile, &gameSettings);
if(fileFound == false) {
throw runtime_error("Specified game settings file [" + loadGameSettingsFile + "] was NOT found!");
throw megaglest_runtime_error("Specified game settings file [" + loadGameSettingsFile + "] was NOT found!");
}
//printf("Got settings:\n%s",gameSettings.toString().c_str());
mainMenu->setState(new MenuStateCustomGame(program, mainMenu, false, pNewGame, true, &gameSettings));

View File

@ -408,7 +408,7 @@ void GraphicListBox::setSelectedItem(string item, bool errorOnMissing){
for(int idx = 0; idx < items.size(); idx++) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d]\ninstanceName [%s] idx = %d items[idx] = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,instanceName.c_str(),idx,items[idx].c_str());
}
throw runtime_error("[" + instanceName +"] Value not found on list box: [" + item + "]");
throw megaglest_runtime_error("[" + instanceName +"] Value not found on list box: [" + item + "]");
}
}
else {

View File

@ -91,7 +91,7 @@ void Logger::clear() {
FILE *f= fopen(fileName.c_str(), "wt+");
#endif
if(f == NULL){
throw runtime_error("Error opening log file" + fileName);
throw megaglest_runtime_error("Error opening log file" + fileName);
}
fprintf(f, "%s", s.c_str());

View File

@ -83,7 +83,7 @@ void ChatManager::keyUp(SDL_KeyboardEvent key) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -300,7 +300,7 @@ void ChatManager::keyDown(SDL_KeyboardEvent key) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -459,7 +459,7 @@ void ChatManager::updateNetwork() {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}

View File

@ -122,7 +122,7 @@ void CommanderNetworkThread::execute() {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -516,7 +516,7 @@ CommandResult Commander::pushNetworkCommand(const NetworkCommand* networkCommand
sprintf(szMsg,"Player detected an error: Command refers to non existent unit id = %d. Game out of synch.",networkCommand->getUnitId());
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
}
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -713,7 +713,7 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
SwitchTeamVote *vote = faction->getSwitchTeamVote(factionIndex);
if(vote == NULL) {
throw runtime_error("vote == NULL");
throw megaglest_runtime_error("vote == NULL");
}
vote->voted = true;
vote->allowSwitchTeam = allowSwitchTeam;
@ -894,7 +894,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
if(world == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] world == NULL for unit with id: %d",__FILE__,__FUNCTION__,__LINE__,networkCommand->getUnitId());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
Unit* target= NULL;
@ -915,7 +915,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
}
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
ct= unit->getType()->findCommandTypeById(networkCommand->getCommandTypeId());
@ -949,7 +949,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
}
std::string sError = "Error [#1]: Game is out of sync (Unit / Faction mismatch)\nplease check log files for details.";
throw runtime_error(sError);
throw megaglest_runtime_error(sError);
}
/*
I don't think we can validate in unit type since it can be different for certain commands (like attack and build etc)
@ -973,14 +973,14 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
}
std::string sError = "Error [#2]: Game is out of sync (unit type mismatch)\nplease check log files for details.";
throw runtime_error(sError);
throw megaglest_runtime_error(sError);
}
*/
const UnitType* unitType= world->findUnitTypeById(unit->getFaction()->getType(), networkCommand->getUnitTypeId());
// debug test!
//throw runtime_error("Test missing command type!");
//throw megaglest_runtime_error("Test missing command type!");
//validate command type
if(ct == NULL) {
@ -1004,7 +1004,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
std::string sError = "Error [#3]: Game is out of sync, please check log files for details.";
//abort();
throw runtime_error(sError);
throw megaglest_runtime_error(sError);
}
CardinalDir facing;
@ -1014,7 +1014,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
if(networkCommand->getTargetId() < 0 || networkCommand->getTargetId() >= 4) {
char szBuf[1024]="";
sprintf(szBuf,"networkCommand->getTargetId() >= 0 && networkCommand->getTargetId() < 4, [%s]",networkCommand->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
facing = CardinalDir(networkCommand->getTargetId());
}

View File

@ -110,7 +110,7 @@ void Console::addLine(string line, bool playSound, int playerIndex, Vec3f textCo
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -144,7 +144,7 @@ void Console::addLine(string line, bool playSound, string playerName, Vec3f text
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -170,25 +170,25 @@ bool Console::isEmpty() {
string Console::getLine(int i) const {
if(i < 0 || i >= lines.size())
throw runtime_error("i >= Lines.size()");
throw megaglest_runtime_error("i >= Lines.size()");
return lines[i].text;
}
string Console::getStoredLine(int i) const {
if(i < 0 || i >= storedLines.size())
throw runtime_error("i >= storedLines.size()");
throw megaglest_runtime_error("i >= storedLines.size()");
return storedLines[i].text;
}
ConsoleLineInfo Console::getLineItem(int i) const {
if(i < 0 || i >= lines.size())
throw runtime_error("i >= Lines.size()");
throw megaglest_runtime_error("i >= Lines.size()");
return lines[i];
}
ConsoleLineInfo Console::getStoredLineItem(int i) const {
if(i < 0 || i >= storedLines.size())
throw runtime_error("i >= storedLines.size()");
throw megaglest_runtime_error("i >= storedLines.size()");
return storedLines[i];
}

View File

@ -726,7 +726,7 @@ void Game::load(int loadTypes) {
}
}
//throw runtime_error("Test!");
//throw megaglest_runtime_error("Test!");
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//tileset
@ -769,7 +769,7 @@ void Game::load(int loadTypes) {
}
errorText += results[i];
}
throw runtime_error(errorText);
throw megaglest_runtime_error(errorText);
}
*/
}
@ -828,7 +828,7 @@ void Game::init(bool initForPreviewOnly) {
NetworkManager &networkManager= NetworkManager::getInstance();
if(map == NULL) {
throw runtime_error("map == NULL");
throw megaglest_runtime_error("map == NULL");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -1010,13 +1010,13 @@ void Game::init(bool initForPreviewOnly) {
if(this->masterserverMode == false) {
if(world.getThisFaction() == NULL) {
throw runtime_error("world.getThisFaction() == NULL");
throw megaglest_runtime_error("world.getThisFaction() == NULL");
}
if(world.getThisFaction()->getType() == NULL) {
throw runtime_error("world.getThisFaction()->getType() == NULL");
throw megaglest_runtime_error("world.getThisFaction()->getType() == NULL");
}
//if(world.getThisFaction()->getType()->getMusic() == NULL) {
// throw runtime_error("world.getThisFaction()->getType()->getMusic() == NULL");
// throw megaglest_runtime_error("world.getThisFaction()->getType()->getMusic() == NULL");
//}
}
@ -2608,7 +2608,7 @@ void Game::keyDown(SDL_KeyboardEvent key) {
}
}
//throw runtime_error("Test Error!");
//throw megaglest_runtime_error("Test Error!");
}
catch(const exception &ex) {
char szBuf[4096]="";
@ -3851,7 +3851,7 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) {
if(gameVer != glestVersionString) {
char szBuf[4096]="";
sprintf(szBuf,lang.get("SavedGameBadVersion").c_str(),gameVer.c_str(),glestVersionString.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found saved game version that matches your application version: [%s] --> [%s]\n",gameVer.c_str(),glestVersionString.c_str());
@ -3912,7 +3912,7 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode) {
if(gameVer != glestVersionString) {
char szBuf[4096]="";
sprintf(szBuf,lang.get("SavedGameBadVersion").c_str(),gameVer.c_str(),glestVersionString.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found saved game version that matches your application version: [%s] --> [%s]\n",gameVer.c_str(),glestVersionString.c_str());

View File

@ -1120,7 +1120,7 @@ void ScriptManager::endGame() {
void ScriptManager::startPerformanceTimer() {
ScriptManager_STREFLOP_Wrapper streflopWrapper;
if(world->getGame() == NULL) {
throw runtime_error("world->getGame() == NULL");
throw megaglest_runtime_error("world->getGame() == NULL");
}
world->getGame()->startPerformanceTimer();
@ -1129,7 +1129,7 @@ void ScriptManager::startPerformanceTimer() {
void ScriptManager::endPerformanceTimer() {
ScriptManager_STREFLOP_Wrapper streflopWrapper;
if(world->getGame() == NULL) {
throw runtime_error("world->getGame() == NULL");
throw megaglest_runtime_error("world->getGame() == NULL");
}
world->getGame()->endPerformanceTimer();
@ -1138,7 +1138,7 @@ void ScriptManager::endPerformanceTimer() {
Vec2i ScriptManager::getPerformanceTimerResults() {
ScriptManager_STREFLOP_Wrapper streflopWrapper;
if(world->getGame() == NULL) {
throw runtime_error("world->getGame() == NULL");
throw megaglest_runtime_error("world->getGame() == NULL");
}
return world->getGame()->getPerformanceTimerResults();
}
@ -1887,7 +1887,7 @@ int ScriptManager::DisplayFormattedText(LuaHandle* luaHandle) {
else {
char szBuf[1024]="";
sprintf(szBuf,"Invalid parameter count in method [%s] args = %d [argument count must be between 1 and %d]",__FUNCTION__,args,max_args_allowed);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//va_end(argList);
@ -1995,7 +1995,7 @@ if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags
else {
char szBuf[1024]="";
sprintf(szBuf,"Invalid parameter count in method [%s] args = %d [argument count must be between 1 and %d]",__FUNCTION__,args,max_args_allowed);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//va_end(argList);
@ -2076,7 +2076,7 @@ int ScriptManager::DisplayFormattedLangText(LuaHandle* luaHandle) {
else {
char szBuf[1024]="";
sprintf(szBuf,"Invalid parameter count in method [%s] args = %d [argument count must be between 1 and %d]",__FUNCTION__,args,max_args_allowed);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//va_end(argList);

View File

@ -576,7 +576,7 @@ char Config::translateStringToCharKey(const string &value) const {
}
else {
string sError = "Unsupported key translation [" + value + "]";
throw runtime_error(sError.c_str());
throw megaglest_runtime_error(sError.c_str());
}
}
else if(value.length() >= 1) {
@ -674,7 +674,7 @@ char Config::translateStringToCharKey(const string &value) const {
}
else {
string sError = "Unsupported key translation" + value;
throw runtime_error(sError.c_str());
throw megaglest_runtime_error(sError.c_str());
}
// Because SDL is based on lower Ascii
@ -755,7 +755,7 @@ SDLKey Config::translateStringToSDLKey(const string &value) const {
}
else {
string sError = "Unsupported key translation [" + value + "]";
throw runtime_error(sError.c_str());
throw megaglest_runtime_error(sError.c_str());
}
}
else if(value.length() >= 1) {
@ -783,7 +783,7 @@ SDLKey Config::translateStringToSDLKey(const string &value) const {
}
else {
string sError = "Unsupported key translation" + value;
throw runtime_error(sError.c_str());
throw megaglest_runtime_error(sError.c_str());
}
// Because SDL is based on lower Ascii

View File

@ -192,7 +192,7 @@ void Lang::loadStrings(string uselanguage, Properties &properties, bool fileMust
}
else if(fileExists(languageFile) == false && fallbackToDefault == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,languageFile.c_str());
//throw runtime_error("File NOT FOUND, can't open file: [" + languageFile + "]");
//throw megaglest_runtime_error("File NOT FOUND, can't open file: [" + languageFile + "]");
printf("Language file NOT FOUND, can't open file: [%s] switching to default language: %s\n",languageFile.c_str(),DEFAULT_LANGUAGE);
languageFile = getGameCustomCoreDataPath(data_path, "data/lang/" + string(DEFAULT_LANGUAGE) + ".lng");
@ -430,7 +430,7 @@ map<string,string> Lang::getDiscoveredLanguageList(bool searchKeyIsLangName) {
vector<string> langResults2;
findAll(data_path + "data/lang/*.lng", langResults2, true);
if(langResults2.empty() && langResults.empty()) {
throw runtime_error("There are no lang files");
throw megaglest_runtime_error("There are no lang files");
}
for(unsigned int i = 0; i < langResults2.size(); ++i) {
string testLanguage = langResults2[i];

View File

@ -10,9 +10,8 @@
// ==============================================================
#include "metrics.h"
//#include "element_type.h"
#include <stdexcept>
#include "platform_util.h"
#include "leak_dumper.h"
using namespace std;
@ -51,21 +50,21 @@ const Metrics &Metrics::getInstance(){
float Metrics::getAspectRatio() const{
if(screenH == 0) {
throw runtime_error("div by 0 screenH == 0");
throw megaglest_runtime_error("div by 0 screenH == 0");
}
return static_cast<float>(screenW)/screenH;
}
int Metrics::toVirtualX(int w) const{
if(screenW == 0) {
throw runtime_error("div by 0 screenW == 0");
throw megaglest_runtime_error("div by 0 screenW == 0");
}
return w*virtualW/screenW;
}
int Metrics::toVirtualY(int h) const{
if(screenH == 0) {
throw runtime_error("div by 0 screenH == 0");
throw megaglest_runtime_error("div by 0 screenH == 0");
}
//printf("h [%d] virtualH [%d] screenH [%d] result = %d\n",h,virtualH,screenH,(h*virtualH/screenH));

View File

@ -167,7 +167,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
if(modelNode->hasChild("cycles")) {
modelCycle = modelNode->getChild("cycles")->getAttribute("value")->getFloatValue();
if(modelCycle < 0.0)
throw runtime_error("negative model cycle value is bad");
throw megaglest_runtime_error("negative model cycle value is bad");
}
}
}
@ -423,7 +423,7 @@ void ParticleSystemTypeProjectile::load(const XmlNode* particleFileNode, const s
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
throw megaglest_runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
}
}
@ -509,7 +509,7 @@ void ParticleSystemTypeSplash::load(const XmlNode* particleFileNode, const strin
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
throw megaglest_runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
}
}

View File

@ -1693,17 +1693,17 @@ void Renderer::renderMouse3d() {
if(game == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s] Line: %d game == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else if(game->getGui() == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s] Line: %d game->getGui() == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else if(game->getGui()->getMouse3d() == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s] Line: %d game->getGui()->getMouse3d() == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const Gui *gui= game->getGui();
@ -1712,7 +1712,7 @@ void Renderer::renderMouse3d() {
if(map == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s] Line: %d map == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
GLUquadricObj *cilQuadric;
@ -1890,7 +1890,7 @@ void Renderer::renderConsoleLine3D(int lineIndex, int xPosition, int yPosition,
headerLine += ": ";
if(fontMetrics == NULL) {
throw runtime_error("fontMetrics == NULL");
throw megaglest_runtime_error("fontMetrics == NULL");
}
renderTextShadow3D(
@ -1917,7 +1917,7 @@ void Renderer::renderConsoleLine3D(int lineIndex, int xPosition, int yPosition,
headerLine += ": ";
if(fontMetrics == NULL) {
throw runtime_error("fontMetrics == NULL");
throw megaglest_runtime_error("fontMetrics == NULL");
}
renderTextShadow3D(
@ -1994,7 +1994,7 @@ void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, in
headerLine += ": ";
if(fontMetrics == NULL) {
throw runtime_error("fontMetrics == NULL");
throw megaglest_runtime_error("fontMetrics == NULL");
}
renderTextShadow(
@ -2019,7 +2019,7 @@ void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, in
headerLine += ": ";
if(fontMetrics == NULL) {
throw runtime_error("fontMetrics == NULL");
throw megaglest_runtime_error("fontMetrics == NULL");
}
renderTextShadow(
@ -2054,7 +2054,7 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,
}
if(console == NULL) {
throw runtime_error("console == NULL");
throw megaglest_runtime_error("console == NULL");
}
glPushAttrib(GL_ENABLE_BIT);
@ -2320,13 +2320,13 @@ void Renderer::renderSelectionQuad() {
Vec2i computeCenteredPos(const string &text, Font2D *font, int x, int y) {
if(font == NULL) {
//abort();
throw runtime_error("font == NULL (1)");
throw megaglest_runtime_error("font == NULL (1)");
}
const Metrics &metrics= Metrics::getInstance();
FontMetrics *fontMetrics= font->getMetrics();
if(fontMetrics == NULL) {
throw runtime_error("fontMetrics == NULL (1)");
throw megaglest_runtime_error("fontMetrics == NULL (1)");
}
int virtualX = (fontMetrics->getTextWidth(text) > 0 ? static_cast<int>(fontMetrics->getTextWidth(text)/2.f) : 5);
@ -2343,13 +2343,13 @@ Vec2i computeCenteredPos(const string &text, Font2D *font, int x, int y) {
Vec2i computeCenteredPos(const string &text, Font3D *font, int x, int y) {
if(font == NULL) {
throw runtime_error("font == NULL (2)");
throw megaglest_runtime_error("font == NULL (2)");
}
const Metrics &metrics= Metrics::getInstance();
FontMetrics *fontMetrics= font->getMetrics();
if(fontMetrics == NULL) {
throw runtime_error("fontMetrics == NULL (2)");
throw megaglest_runtime_error("fontMetrics == NULL (2)");
}
int virtualX = (fontMetrics->getTextWidth(text) > 0 ? static_cast<int>(fontMetrics->getTextWidth(text) / 2.f) : 5);
@ -2433,10 +2433,10 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i
if(centeredW == true) {
if(font == NULL) {
//abort();
throw runtime_error("font == NULL (5)");
throw megaglest_runtime_error("font == NULL (5)");
}
else if(font->getTextHandler() == NULL) {
throw runtime_error("font->getTextHandler() == NULL (5)");
throw megaglest_runtime_error("font->getTextHandler() == NULL (5)");
}
float lineWidth = (font->getTextHandler()->Advance(text.c_str()) * Font::scaleFontValue);
@ -2447,10 +2447,10 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i
if(centeredH) {
if(font == NULL) {
throw runtime_error("font == NULL (6)");
throw megaglest_runtime_error("font == NULL (6)");
}
else if(font->getTextHandler() == NULL) {
throw runtime_error("font->getTextHandler() == NULL (6)");
throw megaglest_runtime_error("font->getTextHandler() == NULL (6)");
}
//const Metrics &metrics= Metrics::getInstance();
@ -2632,7 +2632,7 @@ void Renderer::renderTextShadow3D(const string &text, Font3D *font,const Vec4f &
}
if(font == NULL) {
throw runtime_error("font == NULL (3)");
throw megaglest_runtime_error("font == NULL (3)");
}
glPushAttrib(GL_CURRENT_BIT);
@ -2661,7 +2661,7 @@ void Renderer::renderTextShadow(const string &text, Font2D *font,const Vec4f &co
}
if(font == NULL) {
throw runtime_error("font == NULL (4)");
throw megaglest_runtime_error("font == NULL (4)");
}
glPushAttrib(GL_CURRENT_BIT);
@ -3377,7 +3377,7 @@ void Renderer::renderMessageBox(GraphicMessageBox *messageBox) {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -3984,16 +3984,16 @@ void Renderer::renderSurface(const int renderFps) {
SurfaceCell *tc11= map->getSurfaceCell(pos.x+1, pos.y+1);
if(tc00 == NULL) {
throw runtime_error("tc00 == NULL");
throw megaglest_runtime_error("tc00 == NULL");
}
if(tc10 == NULL) {
throw runtime_error("tc10 == NULL");
throw megaglest_runtime_error("tc10 == NULL");
}
if(tc01 == NULL) {
throw runtime_error("tc01 == NULL");
throw megaglest_runtime_error("tc01 == NULL");
}
if(tc11 == NULL) {
throw runtime_error("tc11 == NULL");
throw megaglest_runtime_error("tc11 == NULL");
}
triangleCount+= 2;
@ -4001,7 +4001,7 @@ void Renderer::renderSurface(const int renderFps) {
//set texture
if(tc00->getSurfaceTexture() == NULL) {
throw runtime_error("tc00->getSurfaceTexture() == NULL");
throw megaglest_runtime_error("tc00->getSurfaceTexture() == NULL");
}
currTex= static_cast<const Texture2DGl*>(tc00->getSurfaceTexture())->getHandle();
if(currTex != lastTex) {
@ -4133,16 +4133,16 @@ void Renderer::renderSurface(const int renderFps) {
SurfaceCell *tc11= map->getSurfaceCell(pos.x+1, pos.y+1);
if(tc00 == NULL) {
throw runtime_error("tc00 == NULL");
throw megaglest_runtime_error("tc00 == NULL");
}
if(tc10 == NULL) {
throw runtime_error("tc10 == NULL");
throw megaglest_runtime_error("tc10 == NULL");
}
if(tc01 == NULL) {
throw runtime_error("tc01 == NULL");
throw megaglest_runtime_error("tc01 == NULL");
}
if(tc11 == NULL) {
throw runtime_error("tc11 == NULL");
throw megaglest_runtime_error("tc11 == NULL");
}
triangleCount+= 2;
@ -4150,7 +4150,7 @@ void Renderer::renderSurface(const int renderFps) {
//set texture
if(tc00->getSurfaceTexture() == NULL) {
throw runtime_error("tc00->getSurfaceTexture() == NULL");
throw megaglest_runtime_error("tc00->getSurfaceTexture() == NULL");
}
int surfaceDataIndex = -1;
@ -4421,7 +4421,7 @@ void Renderer::renderWater() {
if(textures3D){
Texture3D *waterTex= world->getTileset()->getWaterTex();
if(waterTex == NULL) {
throw runtime_error("waterTex == NULL");
throw megaglest_runtime_error("waterTex == NULL");
}
glEnable(GL_TEXTURE_3D);
glBindTexture(GL_TEXTURE_3D, static_cast<Texture3DGl*>(waterTex)->getHandle());
@ -4456,10 +4456,10 @@ void Renderer::renderWater() {
SurfaceCell *tc0= map->getSurfaceCell(i, j);
SurfaceCell *tc1= map->getSurfaceCell(i, j+1);
if(tc0 == NULL) {
throw runtime_error("tc0 == NULL");
throw megaglest_runtime_error("tc0 == NULL");
}
if(tc1 == NULL) {
throw runtime_error("tc1 == NULL");
throw megaglest_runtime_error("tc1 == NULL");
}
int thisTeamIndex= world->getThisTeamIndex();
@ -6532,7 +6532,7 @@ void Renderer::loadConfig() {
textures3D= config.getBool("Textures3D");
float gammaValue=config.getFloat("GammaValue","0.0");
if(this->program == NULL) {
throw runtime_error("this->program == NULL");
throw megaglest_runtime_error("this->program == NULL");
}
//if(this->program != NULL) {
if(gammaValue!=0.0){
@ -6928,7 +6928,7 @@ void Renderer::checkGlCaps() {
message += "MegaGlest needs at least version 1.3 to work\n";
message += "You may solve this problem by installing your latest video card drivers";
throw runtime_error(message.c_str());
throw megaglest_runtime_error(message.c_str());
}
//opengl 1.4 or extension
@ -6946,7 +6946,7 @@ void Renderer::checkGlOptionalCaps() {
//shadows
if(shadows == sProjected || shadows == sShadowMapping) {
if(getGlMaxTextureUnits() < 3) {
throw runtime_error("Your system doesn't support 3 texture units, required for shadows");
throw megaglest_runtime_error("Your system doesn't support 3 texture units, required for shadows");
}
}
@ -6965,7 +6965,7 @@ void Renderer::checkExtension(const string &extension, const string &msg) {
if(!isGlExtensionSupported(extension.c_str())) {
string str= "OpenGL extension not supported: " + extension + ", required for " + msg;
throw runtime_error(str);
throw megaglest_runtime_error(str);
}
}
@ -7613,7 +7613,7 @@ Texture2D::Filter Renderer::strToTextureFilter(const string &s){
return Texture2D::fTrilinear;
}
throw runtime_error("Error converting from string to FilterType, found: "+s);
throw megaglest_runtime_error("Error converting from string to FilterType, found: "+s);
}
void Renderer::setAllowRenderUnitTitles(bool value) {

View File

@ -75,7 +75,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
direction.y= directionNode->getAttribute("y")->getFloatValue();
direction.z= directionNode->getAttribute("z")->getFloatValue();
if((shape == UnitParticleSystem::sConical) && (0.0 == direction.length()))
throw runtime_error("direction cannot be zero");
throw megaglest_runtime_error("direction cannot be zero");
// ought to warn about 0 directions generally
}
@ -96,7 +96,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
const XmlNode *minRadiusNode= particleSystemNode->getChild("min-radius");
minRadius= minRadiusNode->getAttribute("value")->getFloatValue();
if(minRadius > radius)
throw runtime_error("min-radius cannot be bigger than radius");
throw megaglest_runtime_error("min-radius cannot be bigger than radius");
} else {
minRadius = 0;
}
@ -174,7 +174,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
const XmlNode* delayNode = particleSystemNode->getChild("delay");
const float delay_secs = delayNode->getAttribute("value")->getFloatValue();
if(delay_secs < 0)
throw runtime_error("particle effect delay cannot be negative");
throw megaglest_runtime_error("particle effect delay cannot be negative");
delay = (int)delay_secs * GameConstants::updateFps;
} else{
delay= 0;
@ -185,7 +185,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
const XmlNode* lifetimeNode = particleSystemNode->getChild("lifetime");
const float lifetime_secs = lifetimeNode->getAttribute("value")->getFloatValue();
if(lifetime_secs < 0 && lifetime_secs != -1)
throw runtime_error("particle effect lifetime cannot be negative (-1 means inherited from parent particle)");
throw megaglest_runtime_error("particle effect lifetime cannot be negative (-1 means inherited from parent particle)");
lifetime = (int)lifetime_secs * GameConstants::updateFps;
} else{
lifetime= -1; //default
@ -276,7 +276,7 @@ void UnitParticleSystemType::load(const XmlNode *particleFileNode, const string
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
throw megaglest_runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
}
}

View File

@ -56,14 +56,14 @@ void Display::calculateUpDimensions(int index) {
Vec4f Display::getColor() const {
if(currentColor < 0 || currentColor >= colorCount) {
throw runtime_error("currentColor >= colorCount");
throw megaglest_runtime_error("currentColor >= colorCount");
}
return colors[currentColor];
}
void Display::setUpImage(int i, const Texture2D *image)
{
if(i>=upCellCount) throw runtime_error("i>=upCellCount in Display::setUpImage");
if(i>=upCellCount) throw megaglest_runtime_error("i>=upCellCount in Display::setUpImage");
upImages[i]= image;
calculateUpDimensions(i);
}

View File

@ -43,13 +43,8 @@
#include "string_utils.h"
#include "auto_test.h"
// For gcc backtrace on crash!
// To handle signal catching
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
//#include <mcheck.h>
#include <execinfo.h>
#include <cxxabi.h>
#include <signal.h>
#endif
@ -60,10 +55,6 @@
#include <dbghelp.h>
#endif
#include <stdlib.h>
#include "leak_dumper.h"
#ifndef WIN32
#include <poll.h>
@ -72,6 +63,9 @@
#define _strnicmp strncasecmp
#endif
#include <stdlib.h>
#include "leak_dumper.h"
#ifdef WIN32
#ifndef _DEBUG
#ifndef __GNUC__
@ -87,22 +81,22 @@ using namespace Shared::Platform;
using namespace Shared::Util;
using namespace Shared::Graphics;
using namespace Shared::Graphics::Gl;
using namespace Shared::Xml;
using namespace Shared::Xml;
using namespace Shared;
namespace Glest{ namespace Game{
namespace Glest { namespace Game {
bool disableheadless_console = false;
bool disableBacktrace = false;
bool gameInitialized = false;
static string application_binary="";
static string mg_app_name = "";
static string mailStringSupport = "";
static bool sdl_quitCalled = false;
static string mg_app_name = "";
static string mailStringSupport = "";
static bool sdl_quitCalled = false;
Program *mainProgram = NULL;
FileCRCPreCacheThread *preCacheThread=NULL;
string runtimeErrorMsg = "";
bool disableheadless_console = false;
bool disableBacktrace = false;
bool gameInitialized = false;
Program *mainProgram = NULL;
FileCRCPreCacheThread *preCacheThread = NULL;
string runtimeErrorMsg = "";
void cleanupCRCThread() {
if(preCacheThread != NULL) {
@ -281,62 +275,6 @@ public:
message(msg.c_str());
}
#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
static int getFileAndLine(void *address, char *file, size_t flen) {
int line=-1;
const int maxbufSize = 1024;
static char buf[maxbufSize+1]="";
//char *p=NULL;
// prepare command to be executed
// our program need to be passed after the -e parameter
//sprintf (buf, "/usr/bin/addr2line -C -e ./a.out -f -i %lx", addr);
sprintf(buf, "addr2line -C -e %s -f -i %p",application_binary.c_str(),address);
FILE* f = popen (buf, "r");
if (f == NULL) {
perror (buf);
return 0;
}
// get function name
char *ret = fgets (buf, maxbufSize, f);
if(ret == NULL) {
pclose(f);
return 0;
}
// get file and line
ret = fgets (buf, maxbufSize, f);
if(ret == NULL) {
pclose(f);
return 0;
}
if(strlen(buf) > 0 && buf[0] != '?') {
//int l;
char *p = buf;
// file name is until ':'
while(*p != 0 && *p != ':') {
p++;
}
*p++ = 0;
// after file name follows line number
strcpy (file , buf);
sscanf (p,"%d", &line);
}
else {
strcpy (file,"unknown");
line = 0;
}
pclose(f);
return line;
}
#endif
static void logError(const char *msg, bool confirmToConsole) {
string errorLogFile = "error.log";
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
@ -389,7 +327,12 @@ public:
}
}
static void handleRuntimeError(const char *msg) {
static void handleRuntimeError(const megaglest_runtime_error &ex) {
const char *msg = ex.what();
handleRuntimeError(msg,false);
}
static void handleRuntimeError(const char *msg, bool getStackTraceString) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
static bool inErrorNow = false;
@ -411,87 +354,20 @@ public:
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
if(disableBacktrace == false && sdl_quitCalled == false) {
errMsg += "\nStack Trace:\n";
//errMsg += "To find line #'s use:\n";
//errMsg += "readelf --debug-dump=decodedline %s | egrep 0xaddress-of-stack\n";
const size_t max_depth = 25;
void *stack_addrs[max_depth];
size_t stack_depth = backtrace(stack_addrs, max_depth);
char **stack_strings = backtrace_symbols(stack_addrs, stack_depth);
//for (size_t i = 1; i < stack_depth; i++) {
// errMsg += string(stack_strings[i]) + "\n";
//}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
char szBuf[8096]="";
for(size_t i = 1; i < stack_depth; i++) {
void *lineAddress = stack_addrs[i]; //getStackAddress(stackIndex);
size_t sz = 8096; // just a guess, template names will go much wider
char *function = static_cast<char *>(malloc(sz));
char *begin = 0;
char *end = 0;
// find the parentheses and address offset surrounding the mangled name
for (char *j = stack_strings[i]; *j; ++j) {
if (*j == '(') {
begin = j;
}
else if (*j == '+') {
end = j;
}
}
if (begin && end) {
*begin++ = '\0';
*end = '\0';
// found our mangled name, now in [begin, end)
int status;
char *ret = abi::__cxa_demangle(begin, function, &sz, &status);
if (ret) {
// return value may be a realloc() of the input
function = ret;
}
else {
// demangling failed, just pretend it's a C function with no args
strncpy(function, begin, sz);
strncat(function, "()", sz);
function[sz-1] = '\0';
}
//fprintf(out, " %s:%s\n", stack.strings[i], function);
sprintf(szBuf,"%s:%s address [%p]",stack_strings[i],function,lineAddress);
}
else {
// didn't find the mangled name, just print the whole line
//fprintf(out, " %s\n", stack.strings[i]);
sprintf(szBuf,"%s address [%p]",stack_strings[i],lineAddress);
}
errMsg += string(szBuf);
char file[8096]="";
int line = getFileAndLine(lineAddress, file, 8096);
if(line >= 0) {
errMsg += " line: " + intToStr(line);
}
errMsg += "\n";
free(function);
bool gotStackTrace = false;
if(getStackTraceString == true && disableBacktrace == false && sdl_quitCalled == false) {
string stackTrace = getStackTrace();
errMsg += stackTrace;
gotStackTrace = true;
}
free(stack_strings); // malloc()ed by backtrace_symbols
}
#endif
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
logError(errMsg.c_str(),false);
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,errMsg.c_str());
if(gotStackTrace == true) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,errMsg.c_str());
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,errMsg.c_str());
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -628,18 +504,6 @@ public:
}
};
#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
void handleSIGSEGV(int sig) {
char szBuf[4096]="";
sprintf(szBuf, "In [%s::%s Line: %d] Error detected: signal %d:\n",__FILE__,__FUNCTION__,__LINE__, sig);
printf("%s",szBuf);
//abort();
ExceptionHandler::handleRuntimeError(szBuf);
}
#endif
// =====================================================
// class MainWindow
// =====================================================
@ -666,7 +530,7 @@ void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
int vy = metrics.toVirtualY(getH() - y);
if(program == NULL) {
throw runtime_error("In [MainWindow::eventMouseDown] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventMouseDown] ERROR, program == NULL!");
}
//printf("eventMouseDown popupMenu.getVisible() = %d\n",popupMenu.getVisible());
@ -734,7 +598,7 @@ void MainWindow::eventMouseUp(int x, int y, MouseButton mouseButton){
int vy = metrics.toVirtualY(getH() - y);
if(program == NULL) {
throw runtime_error("In [MainWindow::eventMouseUp] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventMouseUp] ERROR, program == NULL!");
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -772,7 +636,7 @@ void MainWindow::eventMouseDoubleClick(int x, int y, MouseButton mouseButton) {
int vy = metrics.toVirtualY(getH() - y);
if(program == NULL) {
throw runtime_error("In [MainWindow::eventMouseDoubleClick] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventMouseDoubleClick] ERROR, program == NULL!");
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -810,7 +674,7 @@ void MainWindow::eventMouseMove(int x, int y, const MouseState *ms){
int vy = metrics.toVirtualY(getH() - y);
if(program == NULL) {
throw runtime_error("In [MainWindow::eventMouseMove] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventMouseMove] ERROR, program == NULL!");
}
program->eventMouseMove(vx, vy, ms);
@ -830,7 +694,7 @@ void MainWindow::eventMouseWheel(int x, int y, int zDelta) {
int vy = metrics.toVirtualY(getH() - y);
if(program == NULL) {
throw runtime_error("In [MainWindow::eventMouseMove] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventMouseMove] ERROR, program == NULL!");
}
ProgramState *programState = program->getState();
@ -869,7 +733,7 @@ void MainWindow::showLanguages() {
vector<string> langResults2;
findAll(data_path + "data/lang/*.lng", langResults2, true);
if(langResults2.empty() && langResults.empty()) {
throw runtime_error("There are no lang files");
throw megaglest_runtime_error("There are no lang files");
}
for(unsigned int i = 0; i < langResults2.size(); ++i) {
string testLanguage = langResults2[i];
@ -909,7 +773,7 @@ void MainWindow::toggleLanguage(string language) {
vector<string> langResults2;
findAll(data_path + "data/lang/*.lng", langResults2, true);
if(langResults2.empty() && langResults.empty()) {
throw runtime_error("There are no lang files");
throw megaglest_runtime_error("There are no lang files");
}
for(unsigned int i = 0; i < langResults2.size(); ++i) {
string testLanguage = langResults2[i];
@ -948,7 +812,7 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
if(program == NULL) {
throw runtime_error("In [MainWindow::eventKeyDown] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventKeyDown] ERROR, program == NULL!");
}
if(popupMenu.getVisible() == true && isKeyPressed(SDLK_ESCAPE,key) == true) {
@ -1073,7 +937,7 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
void MainWindow::eventKeyUp(SDL_KeyboardEvent key) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key);
if(program == NULL) {
throw runtime_error("In [MainWindow::eventKeyUp] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventKeyUp] ERROR, program == NULL!");
}
program->keyUp(key);
@ -1083,7 +947,7 @@ void MainWindow::eventKeyUp(SDL_KeyboardEvent key) {
void MainWindow::eventKeyPress(SDL_KeyboardEvent c) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
if(program == NULL) {
throw runtime_error("In [MainWindow::eventKeyPress] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventKeyPress] ERROR, program == NULL!");
}
program->keyPress(c);
@ -1121,7 +985,7 @@ void MainWindow::eventActivate(bool active) {
void MainWindow::eventResize(SizeState sizeState) {
if(program == NULL) {
throw runtime_error("In [MainWindow::eventResize] ERROR, program == NULL!");
throw megaglest_runtime_error("In [MainWindow::eventResize] ERROR, program == NULL!");
}
program->resize(sizeState);
@ -1497,7 +1361,7 @@ void runTilesetValidationForPath(string tilesetPath, string tilesetName,
sprintf(szBuf,"svn delete \"%s\"",foundFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
throw megaglest_runtime_error("Call to command failed [" + string(szBuf) + "]");
}
}
else {
@ -1599,7 +1463,7 @@ void runTilesetValidationForPath(string tilesetPath, string tilesetName,
sprintf(szBuf,"svn delete \"%s\"",duplicateFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
throw megaglest_runtime_error("Call to command failed [" + string(szBuf) + "]");
}
printf("*** Duplicate file:\n[%s]\nwas svn deleted and copied to:\n[%s]\n",duplicateFile.c_str(),expandedNewCommonFileName.c_str());
}
@ -1610,7 +1474,7 @@ void runTilesetValidationForPath(string tilesetPath, string tilesetName,
char szBuf[4096]="";
char *errmsg = strerror(errno);
sprintf(szBuf,"!!! Error [%s] Could not rename [%s] to [%s]!",errmsg,duplicateFile.c_str(),expandedNewCommonFileName.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else {
printf("*** Duplicate file:\n[%s]\nwas renamed to:\n[%s]\n",duplicateFile.c_str(),expandedNewCommonFileName.c_str());
@ -1623,7 +1487,7 @@ void runTilesetValidationForPath(string tilesetPath, string tilesetName,
sprintf(szBuf,"svn delete \"%s\"",duplicateFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
throw megaglest_runtime_error("Call to command failed [" + string(szBuf) + "]");
}
printf("*** Duplicate file:\n[%s]\nwas svn deleted\n",duplicateFile.c_str());
}
@ -1658,7 +1522,7 @@ void runTilesetValidationForPath(string tilesetPath, string tilesetName,
if(foundText == false) {
char szBuf[4096]="";
sprintf(szBuf,"Error finding text [%s] in file [%s]",searchText.c_str(),parentFile.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
mapUniqueParentList[parentFile]++;
}
@ -1706,7 +1570,7 @@ void runTilesetValidationForPath(string tilesetPath, string tilesetName,
sprintf(szBuf,"Error finding text\n[%s]\nin file\n[%s]\nnew Common File [%s]\n",searchText.c_str(),parentFile.c_str(),newCommonFileName.c_str());
printf("\n\n=================================================\n%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
}
@ -1822,7 +1686,7 @@ void runTechValidationForPath(string techPath, string techName,
errorText = errorText + resultErrors[i];
}
errorText += "\n=====================\n";
//throw runtime_error(errorText);
//throw megaglest_runtime_error(errorText);
printf("%s",errorText.c_str());
}
@ -1845,7 +1709,7 @@ void runTechValidationForPath(string techPath, string techName,
errorText = errorText + resultErrors[i];
}
errorText += "\n=====================\n";
//throw runtime_error(errorText);
//throw megaglest_runtime_error(errorText);
printf("%s",errorText.c_str());
}
@ -1933,7 +1797,7 @@ void runTechValidationForPath(string techPath, string techName,
sprintf(szBuf,"svn delete \"%s\"",foundFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
throw megaglest_runtime_error("Call to command failed [" + string(szBuf) + "]");
}
}
else {
@ -1961,7 +1825,7 @@ void runTechValidationForPath(string techPath, string techName,
// if(crcValue == 0) {
// char szBuf[4096]="";
// sprintf(szBuf,"Error calculating CRC for file [%s]",fileName.c_str());
// throw runtime_error(szBuf);
// throw megaglest_runtime_error(szBuf);
// }
// else {
// printf("** CRC for file [%s] is [%d] and has %d parents\n",fileName.c_str(),crcValue,(int)iterMap->second.size());
@ -2047,7 +1911,7 @@ void runTechValidationForPath(string techPath, string techName,
sprintf(szBuf,"svn delete \"%s\"",duplicateFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
throw megaglest_runtime_error("Call to command failed [" + string(szBuf) + "]");
}
printf("*** Duplicate file:\n[%s]\nwas svn deleted and copied to:\n[%s]\n",duplicateFile.c_str(),expandedNewCommonFileName.c_str());
}
@ -2058,7 +1922,7 @@ void runTechValidationForPath(string techPath, string techName,
char szBuf[4096]="";
char *errmsg = strerror(errno);
sprintf(szBuf,"!!! Error [%s] Could not rename [%s] to [%s]!",errmsg,duplicateFile.c_str(),expandedNewCommonFileName.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else {
printf("*** Duplicate file:\n[%s]\nwas renamed to:\n[%s]\n",duplicateFile.c_str(),expandedNewCommonFileName.c_str());
@ -2071,7 +1935,7 @@ void runTechValidationForPath(string techPath, string techName,
sprintf(szBuf,"svn delete \"%s\"",duplicateFile.c_str());
bool svnOk = executeShellCommand(szBuf,0);
if(svnOk == false) {
throw runtime_error("Call to command failed [" + string(szBuf) + "]");
throw megaglest_runtime_error("Call to command failed [" + string(szBuf) + "]");
}
printf("*** Duplicate file:\n[%s]\nwas svn deleted\n",duplicateFile.c_str());
}
@ -2106,7 +1970,7 @@ void runTechValidationForPath(string techPath, string techName,
if(foundText == false) {
char szBuf[4096]="";
sprintf(szBuf,"Error finding text [%s] in file [%s]",searchText.c_str(),parentFile.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
mapUniqueParentList[parentFile]++;
}
@ -2167,7 +2031,7 @@ void runTechValidationForPath(string techPath, string techName,
sprintf(szBuf,"Error finding text\n[%s]\nin file\n[%s]\nnew Common File [%s]\n",searchText.c_str(),parentFile.c_str(),newCommonFileName.c_str());
printf("\n\n=================================================\n%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
}
@ -2649,7 +2513,7 @@ void CheckForDuplicateData() {
std::sort(maps.begin(),maps.end());
if(maps.empty() == true) {
throw runtime_error("No maps were found!");
throw megaglest_runtime_error("No maps were found!");
}
else if(invalidMapList.empty() == false) {
string errorMsg = "Warning invalid maps were detected (will be ignored):\n";
@ -2696,7 +2560,7 @@ void CheckForDuplicateData() {
if(result != 0) {
char *errmsg = strerror(errno);
sprintf(szBuf,"Error [%s]\nCould not rename [%s] to [%s]!",errmsg,oldFile.c_str(),newFile.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else {
sprintf(szBuf,"map [%s] in [%s]\nwas renamed to [%s]",duplicateMapsToRename[i].c_str(),oldFile.c_str(),newFile.c_str());
@ -2714,7 +2578,7 @@ void CheckForDuplicateData() {
findDirs(tilesetPaths, tileSets, false, true);
if (tileSets.empty()) {
throw runtime_error("No tilesets were found!");
throw megaglest_runtime_error("No tilesets were found!");
}
vector<string> duplicateTilesetsToRename;
@ -2747,7 +2611,7 @@ void CheckForDuplicateData() {
if(result != 0) {
char *errmsg = strerror(errno);
sprintf(szBuf,"Error [%s]\nCould not rename [%s] to [%s]!",errmsg,oldFile.c_str(),newFile.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else {
sprintf(szBuf,"tileset [%s] in [%s]\nwas renamed to [%s]",duplicateTilesetsToRename[i].c_str(),oldFile.c_str(),newFile.c_str());
@ -2770,7 +2634,7 @@ void CheckForDuplicateData() {
vector<string> techTrees;
findDirs(techPaths, techTrees, false, true);
if(techTrees.empty()) {
throw runtime_error("No tech-trees were found!");
throw megaglest_runtime_error("No tech-trees were found!");
}
vector<string> duplicateTechtreesToRename;
@ -2803,7 +2667,7 @@ void CheckForDuplicateData() {
if(result != 0) {
char *errmsg = strerror(errno);
sprintf(szBuf,"Error [%s]\nCould not rename [%s] to [%s]!",errmsg,oldFile.c_str(),newFile.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else {
sprintf(szBuf,"techtree [%s] in [%s]\nwas renamed to [%s]",duplicateTechtreesToRename[i].c_str(),oldFile.c_str(),newFile.c_str());
@ -2831,10 +2695,20 @@ void CheckForDuplicateData() {
int glestMain(int argc, char** argv) {
#ifdef SL_LEAK_DUMP
AllocRegistry memoryLeaks = AllocRegistry::getInstance();
//AllocInfo::set_application_binary(executable_path(argv[0],true));
string &app = AllocInfo::get_application_binary();
app = executable_path(argv[0],true);
//want_full_leak_stacktrace = true;
//want_full_leak_stacktrace_line_numbers = true;
#endif
application_binary= executable_path(argv[0],true);
// printf("START ALLOC char 200\n");
//char *ptr = new char[200];
// printf("END ALLOC char 200\n");
// return -1;
PlatformExceptionHandler::application_binary= executable_path(argv[0],true);
mg_app_name = GameConstants::application_name;
mailStringSupport = mailString;
SystemFlags::ENABLE_THREADED_LOGGING = false;
@ -3817,7 +3691,7 @@ int glestMain(int argc, char** argv) {
showfactions = true;
}
else {
throw runtime_error("unknown command for techtreelist [" + cmd + "]");
throw megaglest_runtime_error("unknown command for techtreelist [" + cmd + "]");
}
printf("Using special command for techtree list [%s]\n",cmd.c_str());
}
@ -4137,7 +4011,7 @@ int glestMain(int argc, char** argv) {
sprintf(szBuf,"File specified for loading a saved game cannot be found: [%s]",fileName.c_str());
printf("\n\n======================================================================================\n%s\n======================================================================================\n\n\n",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
}
@ -4440,7 +4314,7 @@ int glestMain(int argc, char** argv) {
// test
//Shared::Platform::MessageBox(NULL,"Mark's test.","Test",0);
//throw runtime_error("test!");
//throw megaglest_runtime_error("test!");
//ExceptionHandler::DisplayMessage("test!", false);
//Lang &lang= Lang::getInstance();
@ -4476,7 +4350,7 @@ int glestMain(int argc, char** argv) {
printf("Headless server is now running...\n");
}
//throw runtime_error("Test!");
//throw megaglest_runtime_error("Test!");
//main loop
while(program->isShutdownApplicationEnabled() == false && Window::handleEvent()) {
@ -4604,19 +4478,7 @@ int glestMain(int argc, char** argv) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
catch(const exception &e) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL);
if(soundThreadManager) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
}
ExceptionHandler::handleRuntimeError(e.what());
}
catch(const char *e) {
catch(const megaglest_runtime_error &e) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL);
if(soundThreadManager) {
@ -4628,6 +4490,30 @@ int glestMain(int argc, char** argv) {
ExceptionHandler::handleRuntimeError(e);
}
catch(const exception &e) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL);
if(soundThreadManager) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
}
ExceptionHandler::handleRuntimeError(e.what(),true);
}
catch(const char *e) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL);
if(soundThreadManager) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
}
ExceptionHandler::handleRuntimeError(e,true);
}
catch(const string &ex) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL);
@ -4638,7 +4524,7 @@ int glestMain(int argc, char** argv) {
}
}
ExceptionHandler::handleRuntimeError(ex.c_str());
ExceptionHandler::handleRuntimeError(ex.c_str(),true);
}
catch(...) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
@ -4650,7 +4536,7 @@ int glestMain(int argc, char** argv) {
}
}
ExceptionHandler::handleRuntimeError("Unknown error!");
ExceptionHandler::handleRuntimeError("Unknown error!",true);
}
cleanupCRCThread();
@ -4691,8 +4577,18 @@ int glestMain(int argc, char** argv) {
return 0;
}
int glestMainWrapper(int argc, char** argv) {
#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
void handleSIGSEGV(int sig) {
char szBuf[4096]="";
sprintf(szBuf, "In [%s::%s Line: %d] Error detected: signal %d:\n",__FILE__,__FUNCTION__,__LINE__, sig);
printf("%s",szBuf);
//abort();
ExceptionHandler::handleRuntimeError(szBuf,true);
}
#endif
int glestMainWrapper(int argc, char** argv) {
//setlocale(LC_ALL, "zh_TW.UTF-8");
//setlocale(LC_ALL, "");

View File

@ -758,7 +758,7 @@ void Program::setDisplaySettings(){
if(!(changeVideoMode(screenWidth, screenHeight, colorBits, freq) ||
changeVideoMode(screenWidth, screenHeight, colorBits, 0)))
{
throw runtime_error(
throw megaglest_runtime_error(
"Error setting video mode: " +
intToStr(screenWidth) + "x" + intToStr(screenHeight) + "x" + intToStr(colorBits));
}

View File

@ -417,7 +417,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
// vector<string> invalidMapList;
// vector<string> allMaps = MapPreview::findAllValidMaps(pathList,scenarioDir,false,true,&invalidMapList);
// if (allMaps.empty()) {
// throw runtime_error("No maps were found!");
// throw megaglest_runtime_error("No maps were found!");
// }
// results.clear();
// copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
@ -520,7 +520,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
showMessageBox( szBuf, "Error", false);
//throw runtime_error(szBuf);
//throw megaglest_runtime_error(szBuf);
}
}
resultsScenarios.clear();
@ -1518,7 +1518,7 @@ void MenuStateConnectedGame::reloadFactions(bool keepExistingSelectedItem, strin
}
if(results.empty() == true) {
//throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
//throw megaglest_runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
//showGeneralError=true;
//generalErrorToShow = "[#2] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]";
}
@ -1979,7 +1979,7 @@ void MenuStateConnectedGame::render() {
}
if(fontMetrics == NULL) {
throw runtime_error("fontMetrics == NULL");
throw megaglest_runtime_error("fontMetrics == NULL");
}
int curWidth = (metrics.toVirtualX(fontMetrics->getTextWidth(labelPlayers[i].getText())));
@ -2170,7 +2170,7 @@ void MenuStateConnectedGame::render() {
char szBuf[8096]="";
sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -2799,7 +2799,7 @@ void MenuStateConnectedGame::update() {
sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,szBuf);
//throw runtime_error(szBuf);
//throw megaglest_runtime_error(szBuf);
showMessageBox( szBuf, "Error", false);
}
@ -2837,7 +2837,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
ClientInterface* clientInterface= networkManager.getClientInterface();
if(clientInterface->getAllowGameDataSynchCheck() == false) {
if(errorOnNoFactions == true) {
throw runtime_error("(2)There are no factions for the tech tree [" + gameSettings->getTech() + "]");
throw megaglest_runtime_error("(2)There are no factions for the tech tree [" + gameSettings->getTech() + "]");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (2)There are no factions for the tech tree [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,gameSettings->getTech().c_str());
}
@ -3497,7 +3497,7 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
vector<string> maps,tilesets,techtree;
if(gameSettings == NULL) {
throw runtime_error("gameSettings == NULL");
throw megaglest_runtime_error("gameSettings == NULL");
}
checkBoxScenario.setValue((gameSettings->getScenario() != ""));
@ -3943,7 +3943,7 @@ int MenuStateConnectedGame::setupMapList(string scenario) {
}
if (allMaps.empty()) {
throw runtime_error("No maps were found!");
throw megaglest_runtime_error("No maps were found!");
}
vector<string> results;
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
@ -3965,7 +3965,7 @@ int MenuStateConnectedGame::setupMapList(string scenario) {
if(GameConstants::maxPlayers+1 <= mapInfo.players) {
char szBuf[1024]="";
sprintf(szBuf,"Sorted map list [%d] does not match\ncurrent map playercount [%d]\nfor file [%s]\nmap [%s]",GameConstants::maxPlayers+1,mapInfo.players,Map::getMapPath(mapFiles.at(i), "", false).c_str(),mapInfo.desc.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
playerSortedMaps[mapInfo.players].push_back(mapFiles.at(i));
formattedPlayerSortedMaps[mapInfo.players].push_back(formatString(mapFiles.at(i)));
@ -3995,7 +3995,7 @@ int MenuStateConnectedGame::setupMapList(string scenario) {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
//abort();
}
@ -4013,7 +4013,7 @@ int MenuStateConnectedGame::setupTechList(string scenario) {
findDirs(techPaths, results);
if(results.empty()) {
throw runtime_error("No tech-trees were found!");
throw megaglest_runtime_error("No tech-trees were found!");
}
techTreeFiles= results;
@ -4035,7 +4035,7 @@ int MenuStateConnectedGame::setupTechList(string scenario) {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return initialTechSelection;
@ -4050,7 +4050,7 @@ void MenuStateConnectedGame::setupTilesetList(string scenario) {
vector<string> results;
findDirs(config.getPathListForType(ptTilesets,scenarioDir), results);
if (results.empty()) {
throw runtime_error("No tile-sets were found!");
throw megaglest_runtime_error("No tile-sets were found!");
}
tilesetFiles= results;
std::for_each(results.begin(), results.end(), FormatString());
@ -4063,7 +4063,7 @@ void MenuStateConnectedGame::setupTilesetList(string scenario) {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}

View File

@ -514,7 +514,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
// if(results.empty() == true) {
if(factionFiles.empty() == true) {
//throw runtime_error("(1)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
//throw megaglest_runtime_error("(1)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
showGeneralError=true;
generalErrorToShow = "[#1] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]";
}
@ -632,7 +632,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
showGeneralError=true;
generalErrorToShow = szBuf;
//throw runtime_error(szBuf);
//throw megaglest_runtime_error(szBuf);
}
}
resultsScenarios.clear();
@ -666,7 +666,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -1751,7 +1751,7 @@ void MenuStateCustomGame::render() {
fontMetrics = labelPlayers[i].getFont3D()->getMetrics();
}
if(fontMetrics == NULL) {
throw runtime_error("fontMetrics == NULL");
throw megaglest_runtime_error("fontMetrics == NULL");
}
//int curWidth = (metrics.toVirtualX(fontMetrics->getTextWidth(labelPlayers[i].getText())));
int curWidth = (fontMetrics->getTextWidth(labelPlayers[i].getText()));
@ -1917,7 +1917,7 @@ void MenuStateCustomGame::render() {
catch(const std::exception &ex) {
char szBuf[8096]="";
sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
//throw runtime_error(szBuf);
//throw megaglest_runtime_error(szBuf);
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
@ -2785,7 +2785,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
if(callingThread->getQuitStatus() == false) {
//throw runtime_error(szBuf);
//throw megaglest_runtime_error(szBuf);
showGeneralError=true;
generalErrorToShow = ex.what();
}
@ -3453,7 +3453,7 @@ void MenuStateCustomGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMa
}
catch(exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] loading map [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),file.c_str());
throw runtime_error("Error loading map file: [" + file + "] msg: " + e.what());
throw megaglest_runtime_error("Error loading map file: [" + file + "] msg: " + e.what());
}
}
@ -3488,7 +3488,7 @@ void MenuStateCustomGame::updateControlers() {
char szBuf[8096]="";
sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -3514,7 +3514,7 @@ void MenuStateCustomGame::closeUnusedSlots(){
char szBuf[8096]="";
sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -3586,7 +3586,7 @@ void MenuStateCustomGame::updateNetworkSlots() {
sprintf(szBuf,"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);
//throw runtime_error(szBuf);
//throw megaglest_runtime_error(szBuf);
showGeneralError=true;
generalErrorToShow = szBuf;
@ -4114,7 +4114,7 @@ void MenuStateCustomGame::SetupUIForScenarios() {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -4136,7 +4136,7 @@ int MenuStateCustomGame::setupMapList(string scenario) {
}
if (allMaps.empty()) {
throw runtime_error("No maps were found!");
throw megaglest_runtime_error("No maps were found!");
}
vector<string> results;
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
@ -4158,7 +4158,7 @@ int MenuStateCustomGame::setupMapList(string scenario) {
if(GameConstants::maxPlayers+1 <= mapInfo.players) {
char szBuf[1024]="";
sprintf(szBuf,"Sorted map list [%d] does not match\ncurrent map playercount [%d]\nfor file [%s]\nmap [%s]",GameConstants::maxPlayers+1,mapInfo.players,Map::getMapPath(mapFiles.at(i), "", false).c_str(),mapInfo.desc.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
playerSortedMaps[mapInfo.players].push_back(mapFiles.at(i));
formattedPlayerSortedMaps[mapInfo.players].push_back(formatString(mapFiles.at(i)));
@ -4190,7 +4190,7 @@ int MenuStateCustomGame::setupMapList(string scenario) {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
//abort();
}
@ -4208,7 +4208,7 @@ int MenuStateCustomGame::setupTechList(string scenario) {
findDirs(techPaths, results);
if(results.empty()) {
throw runtime_error("No tech-trees were found!");
throw megaglest_runtime_error("No tech-trees were found!");
}
techTreeFiles= results;
@ -4230,7 +4230,7 @@ int MenuStateCustomGame::setupTechList(string scenario) {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return initialTechSelection;
@ -4260,7 +4260,7 @@ void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem, string s
}
if(results.empty() == true) {
//throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
//throw megaglest_runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
showGeneralError=true;
generalErrorToShow = "[#2] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]";
}
@ -4309,7 +4309,7 @@ void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem, string s
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -4322,7 +4322,7 @@ void MenuStateCustomGame::setupTilesetList(string scenario) {
vector<string> results;
findDirs(config.getPathListForType(ptTilesets,scenarioDir), results);
if (results.empty()) {
throw runtime_error("No tile-sets were found!");
throw megaglest_runtime_error("No tile-sets were found!");
}
tilesetFiles= results;
std::for_each(results.begin(), results.end(), FormatString());
@ -4335,7 +4335,7 @@ void MenuStateCustomGame::setupTilesetList(string scenario) {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}

View File

@ -106,7 +106,7 @@ MenuStateKeysetup::MenuStateKeysetup(Program *program, MainMenu *mainMenu,
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//throw runtime_error("Test!");
//throw megaglest_runtime_error("Test!");
for(int i = 0; i < mergedProperties.size(); ++i) {

View File

@ -814,7 +814,7 @@ void MenuStateMasterserver::update() {
pCB_DisplayMessage(sError.c_str(),false);
}
else {
throw runtime_error(sError.c_str());
throw megaglest_runtime_error(sError.c_str());
}
}
}

View File

@ -806,7 +806,7 @@ MapInfo MenuStateMods::loadMapInfo(string file) {
}
catch(exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] loading map [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what(),file.c_str());
throw runtime_error("Error loading map file: [" + file + "] msg: " + e.what());
throw megaglest_runtime_error("Error loading map file: [" + file + "] msg: " + e.what());
}
return mapInfo;
@ -820,7 +820,7 @@ MapInfo MenuStateMods::loadMapInfo(string file) {
}
catch(exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] loading map [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what(),file.c_str());
throw runtime_error("Error loading map file: [" + file + "] msg: " + e.what());
throw megaglest_runtime_error("Error loading map file: [" + file + "] msg: " + e.what());
}
return mapInfo;
@ -979,7 +979,7 @@ void MenuStateMods::getMapsLocalList() {
vector<string> invalidMapList;
vector<string> allMaps = MapPreview::findAllValidMaps(pathList,scenarioDir,false,false,&invalidMapList);
if (allMaps.empty()) {
throw runtime_error("No maps were found!");
throw megaglest_runtime_error("No maps were found!");
}
vector<string> results;
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
@ -2190,7 +2190,7 @@ void MenuStateMods::render() {
if(i >= keyScenarioButtons.size()) {
char szBuf[1024]="";
sprintf(szBuf,"i >= keyScenarioButtons.size(), i = %d keyScenarioButtons.size() = %d",i,(int)keyScenarioButtons.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
bool alreadyHasScenario = (std::find(scenarioFiles.begin(),scenarioFiles.end(),keyScenarioButtons[i]->getText()) != scenarioFiles.end());
@ -2277,7 +2277,7 @@ void MenuStateMods::render() {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -2294,7 +2294,7 @@ void MenuStateMods::update() {
if(i >= keyTechButtons.size()) {
char szBuf[1024]="";
sprintf(szBuf,"i >= keyTechButtons.size(), i = %d, keyTechButtons.size() = %d",i,(int)keyTechButtons.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
keyTechButtons[i]->setY(keyButtonsYBase - keyButtonsLineHeight * (i
@ -2311,7 +2311,7 @@ void MenuStateMods::update() {
if(i >= keyTilesetButtons.size()) {
char szBuf[1024]="";
sprintf(szBuf,"i >= keyTilesetButtons.size(), i = %d, keyTilesetButtons.size() = %d",i,(int)keyTilesetButtons.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
int yPos = keyButtonsYBase - keyButtonsLineHeight *
@ -2327,7 +2327,7 @@ void MenuStateMods::update() {
if(i >= keyMapButtons.size()) {
char szBuf[1024]="";
sprintf(szBuf,"i >= keyMapButtons.size(), i = %d, keyMapButtons.size() = %d",i,(int)keyMapButtons.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
keyMapButtons[i]->setY(keyButtonsYBase - keyButtonsLineHeight * (i
@ -2344,7 +2344,7 @@ void MenuStateMods::update() {
if(i >= keyScenarioButtons.size()) {
char szBuf[1024]="";
sprintf(szBuf,"i >= keyScenarioButtons.size(), i = %d, keyScenarioButtons.size() = %d",i,(int)keyScenarioButtons.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
int yPos = keyButtonsYBase - keyButtonsLineHeight *

View File

@ -327,7 +327,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
// vector<string> langResults2;
// findAll(data_path + "data/lang/*.lng", langResults2, true);
// if(langResults2.empty() && langResults.empty()) {
// throw runtime_error("There are no lang files");
// throw megaglest_runtime_error("There are no lang files");
// }
// for(unsigned int i = 0; i < langResults2.size(); ++i) {
// string testLanguage = langResults2[i];
@ -558,7 +558,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
}
catch(exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error loading options: %s\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error(string("Error loading options msg: ") + e.what());
throw megaglest_runtime_error(string("Error loading options msg: ") + e.what());
}
}

View File

@ -96,7 +96,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu, const
//printf("scenarioFiles[0] [%s]\n",scenarioFiles[0].c_str());
if(results.empty() == true) {
throw runtime_error("There are no scenarios found to load");
throw megaglest_runtime_error("There are no scenarios found to load");
}
for(int i= 0; i<results.size(); ++i){
results[i] = formatString(results[i]);
@ -306,12 +306,12 @@ void MenuStateScenario::loadGameSettings(const ScenarioInfo *scenarioInfo, GameS
if(listBoxScenario.getSelectedItemIndex() < 0) {
char szBuf[1024]="";
sprintf(szBuf,"listBoxScenario.getSelectedItemIndex() < 0, = %d",listBoxScenario.getSelectedItemIndex());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else if(listBoxScenario.getSelectedItemIndex() >= scenarioFiles.size()) {
char szBuf[1024]="";
sprintf(szBuf,"listBoxScenario.getSelectedItemIndex() >= scenarioFiles.size(), = [%d][%d]",listBoxScenario.getSelectedItemIndex(),(int)scenarioFiles.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
Scenario::loadGameSettings(dirList,scenarioInfo, gameSettings, formatString(scenarioFiles[listBoxScenario.getSelectedItemIndex()]));

View File

@ -487,7 +487,7 @@ void ClientInterface::updateLobby() {
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] Invalid networkMessageLaunch.getMessageType() = %d",__FILE__,__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
networkMessageLaunch.buildGameSettings(&gameSettings);
@ -529,7 +529,7 @@ void ClientInterface::updateLobby() {
default:
{
string sErr = string(__FILE__) + "::" + string(__FUNCTION__) + " Unexpected network message: " + intToStr(networkMessageType);
//throw runtime_error(string(__FILE__) + "::" + string(__FUNCTION__) + " Unexpected network message: " + intToStr(networkMessageType));
//throw megaglest_runtime_error(string(__FILE__) + "::" + string(__FUNCTION__) + " Unexpected network message: " + intToStr(networkMessageType));
sendTextMessage("Unexpected network message: " + intToStr(networkMessageType),-1, true,"");
DisplayErrorMessage(sErr);
sleep(1);
@ -582,7 +582,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
NetworkMessageCommandList networkMessageCommandList;
bool gotCmd = receiveMessage(&networkMessageCommandList);
if(gotCmd == false) {
throw runtime_error("error retrieving nmtCommandList returned false!");
throw megaglest_runtime_error("error retrieving nmtCommandList returned false!");
}
// while(receiveMessage(&networkMessageCommandList) == false &&
@ -646,7 +646,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
// }
bool gotCmd = receiveMessage(&networkMessageQuit);
if(gotCmd == false) {
throw runtime_error("error retrieving nmtQuit returned false!");
throw megaglest_runtime_error("error retrieving nmtQuit returned false!");
}
quit= true;
@ -664,7 +664,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
// }
bool gotCmd = receiveMessage(&networkMessageText);
if(gotCmd == false) {
throw runtime_error("error retrieving nmtText returned false!");
throw megaglest_runtime_error("error retrieving nmtText returned false!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -692,7 +692,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] Invalid networkMessageLaunch.getMessageType() = %d",__FILE__,__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
networkMessageLaunch.buildGameSettings(&gameSettings);
@ -944,7 +944,8 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
return;
}
else {
if(chrono.getMillis() / 1000 > lastMillisCheck) {
//if(chrono.getMillis() / 1000 > lastMillisCheck) {
if(chrono.getMillis() % 100 == 0) {
lastMillisCheck = (chrono.getMillis() / 1000);
char szBuf[1024]="";
@ -1032,6 +1033,8 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
sprintf(szBuf1,statusTextFormat.c_str(),waitForHosts.c_str());
logger.add(szBuf, true, szBuf1);
sleep(0);
}
}
}
@ -1201,7 +1204,7 @@ NetworkMessageType ClientInterface::waitForMessage()
if(msg == nmtInvalid) {
if(chrono.getMillis() % 250 == 0 && isConnected() == false) {
if(quit == false) {
//throw runtime_error("Disconnected");
//throw megaglest_runtime_error("Disconnected");
//sendTextMessage("Server has Disconnected.",-1);
DisplayErrorMessage("Server has Disconnected.");
quit= true;
@ -1212,7 +1215,7 @@ NetworkMessageType ClientInterface::waitForMessage()
if(chrono.getMillis() > messageWaitTimeout) {
//if(1) {
//throw runtime_error("Timeout waiting for message");
//throw megaglest_runtime_error("Timeout waiting for message");
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -230,7 +230,7 @@ void ConnectionSlotThread::execute() {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -565,7 +565,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got nmtCommandList gotIntro = %d\n",__FILE__,__FUNCTION__,__LINE__,gotIntro);
//throw runtime_error("test");
//throw megaglest_runtime_error("test");
if(gotIntro == true) {
NetworkMessageCommandList networkMessageCommandList;
@ -711,7 +711,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] Invalid networkMessageLaunch.getMessageType() = %d",__FILE__,__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
GameSettings gameSettingsBuffer;
@ -989,7 +989,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] networkMessageType = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageType);
if(gotIntro == true) {
//throw runtime_error("Unexpected message in connection slot: " + intToStr(networkMessageType));
//throw megaglest_runtime_error("Unexpected message in connection slot: " + intToStr(networkMessageType));
string sErr = "Unexpected message in connection slot: " + intToStr(networkMessageType);
//sendTextMessage(sErr,-1);
//DisplayErrorMessage(sErr);

View File

@ -67,7 +67,7 @@ NetworkMessageType NetworkInterface::getNextMessageType()
//sanity check new message type
if(messageType < 0 || messageType >= nmtCount) {
if(getConnectHasHandshaked() == true) {
throw runtime_error("Invalid message type: " + intToStr(messageType));
throw megaglest_runtime_error("Invalid message type: " + intToStr(messageType));
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Invalid message type = %d (no packet handshake yet so ignored)\n",__FILE__,__FUNCTION__,__LINE__,messageType);
@ -104,7 +104,7 @@ void NetworkInterface::DisplayErrorMessage(string sErr, bool closeSocket) {
pCB_DisplayMessage(sErr.c_str(), false);
}
else {
throw runtime_error(sErr);
throw megaglest_runtime_error(sErr);
}
}

View File

@ -87,7 +87,7 @@ GameNetworkInterface* NetworkManager::getGameNetworkInterface(bool throwErrorOnN
assert(gameNetworkInterface!=NULL);
if(gameNetworkInterface==NULL) {
throw runtime_error("gameNetworkInterface==NULL");
throw megaglest_runtime_error("gameNetworkInterface==NULL");
}
}
return gameNetworkInterface;
@ -97,12 +97,12 @@ ServerInterface* NetworkManager::getServerInterface(bool throwErrorOnNull) {
if(throwErrorOnNull) {
assert(gameNetworkInterface!=NULL);
if(gameNetworkInterface==NULL) {
throw runtime_error("gameNetworkInterface==NULL");
throw megaglest_runtime_error("gameNetworkInterface==NULL");
}
assert(networkRole==nrServer);
if(networkRole!=nrServer) {
throw runtime_error("networkRole!=nrServer");
throw megaglest_runtime_error("networkRole!=nrServer");
}
}
return dynamic_cast<ServerInterface*>(gameNetworkInterface);
@ -114,12 +114,12 @@ ClientInterface* NetworkManager::getClientInterface(bool throwErrorOnNull) {
if(throwErrorOnNull) {
assert(gameNetworkInterface!=NULL);
if(gameNetworkInterface==NULL) {
throw runtime_error("gameNetworkInterface==NULL");
throw megaglest_runtime_error("gameNetworkInterface==NULL");
}
assert(networkRole==nrClient);
if(networkRole!=nrClient) {
throw runtime_error("networkRole!=nrClient");
throw megaglest_runtime_error("networkRole!=nrClient");
}
}
return dynamic_cast<ClientInterface*>(gameNetworkInterface);

View File

@ -42,7 +42,7 @@ bool NetworkMessage::receive(Socket* socket, void* data, int dataSize, bool tryR
int dataReceived = socket->receive(data, dataSize, tryReceiveUntilDataSizeMet);
if(dataReceived != dataSize) {
if(socket != NULL && socket->getSocketId() > 0) {
throw runtime_error("Error receiving NetworkMessage, dataReceived = " + intToStr(dataReceived) + ", dataSize = " + intToStr(dataSize));
throw megaglest_runtime_error("Error receiving NetworkMessage, dataReceived = " + intToStr(dataReceived) + ", dataSize = " + intToStr(dataSize));
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] socket has been disconnected\n",__FILE__,__FUNCTION__,__LINE__);
@ -66,7 +66,7 @@ void NetworkMessage::send(Socket* socket, const void* data, int dataSize) const
if(socket != NULL && socket->getSocketId() > 0) {
char szBuf[1024]="";
sprintf(szBuf,"Error sending NetworkMessage, sendResult = %d, dataSize = %d",sendResult,dataSize);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d socket has been disconnected\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -111,7 +111,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
copy(results.begin(), results.end(), std::inserter(allMaps, allMaps.begin()));
results.clear();
if (allMaps.empty()) {
throw runtime_error("No maps were found!");
throw megaglest_runtime_error("No maps were found!");
}
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
mapFiles = results;
@ -124,7 +124,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
vector<string> invalidMapList;
vector<string> allMaps = MapPreview::findAllValidMaps(pathList,scenarioDir,false,true,&invalidMapList);
if (allMaps.empty()) {
throw runtime_error("No maps were found!");
throw megaglest_runtime_error("No maps were found!");
}
results.clear();
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
@ -135,7 +135,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
results.clear();
findDirs(config.getPathListForType(ptTilesets), results);
if (results.empty()) {
throw runtime_error("No tile-sets were found!");
throw megaglest_runtime_error("No tile-sets were found!");
}
tilesetFiles= results;
@ -143,7 +143,7 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
results.clear();
findDirs(config.getPathListForType(ptTechs), results);
if(results.empty()) {
throw runtime_error("No tech-trees were found!");
throw megaglest_runtime_error("No tech-trees were found!");
}
techTreeFiles= results;
@ -280,6 +280,16 @@ ServerInterface::~ServerInterface() {
delete serverSocketAdmin;
serverSocketAdmin = NULL;
for(int i = 0; i < broadcastMessageQueue.size(); ++i) {
pair<const NetworkMessage *,int> &item = broadcastMessageQueue[i];
if(item.first != NULL) {
delete item.first;
}
item.first = NULL;
}
broadcastMessageQueue.clear();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -762,7 +772,7 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -1448,7 +1458,7 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
return;
}
else {
if(chrono.getMillis() % 250 == 0) {
if(chrono.getMillis() % 100 == 0) {
string waitForHosts = "";
for(int i = 0; i < waitingForHosts.size(); i++) {
if(waitForHosts != "") {
@ -1541,6 +1551,8 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
connectionSlot->sendMessage(&networkMessageLoadingStatus);
}
}
sleep(0);
}
}
}

View File

@ -163,7 +163,7 @@ void Faction::sortUnitsByCommandGroups() {
// // printf("i = %d [%p]\n",i,&units[i]);
// if(Unit::isUnitDeleted(units[i]) == true) {
// printf("i = %d [%p]\n",i,&units[i]);
// throw runtime_error("unit already deleted!");
// throw megaglest_runtime_error("unit already deleted!");
// }
//}
//printf("\nSorting\n");
@ -327,7 +327,7 @@ void FactionThread::execute() {
for(int j = 0; j < unitCount; ++j) {
Unit *unit = faction->getUnit(j);
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
bool update = unit->needToUpdate();
@ -356,7 +356,7 @@ void FactionThread::execute() {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -715,7 +715,7 @@ int Faction::getCountForMaxUnitCount(const UnitType *unitType) const{
bool Faction::reqsOk(const CommandType *ct) const {
assert(ct != NULL);
if(ct == NULL) {
throw runtime_error("In [Faction::reqsOk] ct == NULL");
throw megaglest_runtime_error("In [Faction::reqsOk] ct == NULL");
}
if(ct->getProduced() != NULL && reqsOk(ct->getProduced()) == false) {
@ -757,14 +757,14 @@ bool Faction::applyCosts(const ProducibleType *p,const CommandType *ct) {
if(r == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"cannot apply costs for p [%s] %d of %d costs resource is null",p->getName().c_str(),i,p->getCostCount());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const ResourceType *rt= r->getType();
if(rt == NULL) {
char szBuf[1024]="";
sprintf(szBuf,"cannot apply costs for p [%s] %d of %d costs resourcetype [%s] is null",p->getName().c_str(),i,p->getCostCount(),r->getDescription().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
int cost= r->getAmount();
if((cost > 0 || (rt->getClass() != rcStatic)) && rt->getClass() != rcConsumable)
@ -809,7 +809,7 @@ void Faction::applyStaticCosts(const ProducibleType *p,const CommandType *ct) {
const ResourceType *rt= p->getCost(i)->getType();
//assert(rt != NULL);
if(rt == NULL) {
throw runtime_error(string(__FUNCTION__) + " rt == NULL for ProducibleType [" + p->getName() + "] index: " + intToStr(i));
throw megaglest_runtime_error(string(__FUNCTION__) + " rt == NULL for ProducibleType [" + p->getName() + "] index: " + intToStr(i));
}
if(rt->getClass() == rcStatic) {
int cost= p->getCost(i)->getAmount();
@ -1079,7 +1079,7 @@ void Faction::removeUnit(Unit *unit){
}
}
throw runtime_error("Could not remove unit from faction!");
throw megaglest_runtime_error("Could not remove unit from faction!");
assert(false);
}

View File

@ -111,10 +111,10 @@ void UnitPathBasic::incBlockCount() {
void UnitPathBasic::add(const Vec2i &path) {
if(this->map != NULL) {
if(this->map->isInside(path) == false) {
throw runtime_error("Invalid map path position = " + path.getString() + " map w x h = " + intToStr(map->getW()) + " " + intToStr(map->getH()));
throw megaglest_runtime_error("Invalid map path position = " + path.getString() + " map w x h = " + intToStr(map->getW()) + " " + intToStr(map->getH()));
}
else if(this->map->isInsideSurface(this->map->toSurfCoords(path)) == false) {
throw runtime_error("Invalid map surface path position = " + path.getString() + " map surface w x h = " + intToStr(map->getSurfaceW()) + " " + intToStr(map->getSurfaceH()));
throw megaglest_runtime_error("Invalid map surface path position = " + path.getString() + " map surface w x h = " + intToStr(map->getSurfaceW()) + " " + intToStr(map->getSurfaceH()));
}
}
@ -124,10 +124,10 @@ void UnitPathBasic::add(const Vec2i &path) {
void UnitPathBasic::addToLastPathCache(const Vec2i &path) {
if(this->map != NULL) {
if(this->map->isInside(path) == false) {
throw runtime_error("Invalid map path position = " + path.getString() + " map w x h = " + intToStr(map->getW()) + " " + intToStr(map->getH()));
throw megaglest_runtime_error("Invalid map path position = " + path.getString() + " map w x h = " + intToStr(map->getW()) + " " + intToStr(map->getH()));
}
else if(this->map->isInsideSurface(this->map->toSurfCoords(path)) == false) {
throw runtime_error("Invalid map surface path position = " + path.getString() + " map surface w x h = " + intToStr(map->getSurfaceW()) + " " + intToStr(map->getSurfaceH()));
throw megaglest_runtime_error("Invalid map surface path position = " + path.getString() + " map surface w x h = " + intToStr(map->getSurfaceW()) + " " + intToStr(map->getSurfaceH()));
}
}
@ -139,7 +139,7 @@ void UnitPathBasic::addToLastPathCache(const Vec2i &path) {
Vec2i UnitPathBasic::pop(bool removeFrontPos) {
if(pathQueue.size() <= 0) {
throw runtime_error("pathQueue.size() = " + intToStr(pathQueue.size()));
throw megaglest_runtime_error("pathQueue.size() = " + intToStr(pathQueue.size()));
}
Vec2i p= pathQueue.front();
if(removeFrontPos == true) {
@ -259,7 +259,7 @@ void UnitReference::loadGame(const XmlNode *rootNode,World *world) {
if(factionIndex >= world->getFactionCount()) {
char szBuf[4096]="";
sprintf(szBuf,"factionIndex >= world->getFactionCount() [%d] : [%d]",factionIndex,world->getFactionCount());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
faction = world->getFaction(factionIndex);
}
@ -403,7 +403,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
RandomGen random;
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
throw runtime_error("#2 Invalid path position = " + pos.getString());
throw megaglest_runtime_error("#2 Invalid path position = " + pos.getString());
}
this->pos=pos;
@ -605,7 +605,7 @@ Vec2i Unit::getCenteredPos() const {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return pos + Vec2i(type->getSize()/2, type->getSize()/2);
@ -615,7 +615,7 @@ Vec2f Unit::getFloatCenteredPos() const {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return Vec2f(pos.x-0.5f+type->getSize()/2.f, pos.y-0.5f+type->getSize()/2.f);
@ -625,7 +625,7 @@ Vec2i Unit::getCellPos() const {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(type->hasCellMap()) {
@ -756,7 +756,7 @@ float Unit::getHpRatio() const {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return clamp(static_cast<float>(hp)/type->getTotalMaxHp(&totalUpgrade), 0.f, 1.f);
@ -766,7 +766,7 @@ float Unit::getEpRatio() const {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(type->getMaxHp()==0){
@ -781,7 +781,7 @@ const Level *Unit::getNextLevel() const{
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(level==NULL && type->getLevelCount()>0){
@ -803,7 +803,7 @@ string Unit::getFullName() const{
str += (level->getName() + " ");
}
if(type == NULL) {
throw runtime_error("type == NULL in Unit::getFullName()!");
throw megaglest_runtime_error("type == NULL in Unit::getFullName()!");
}
str += type->getName();
return str;
@ -819,7 +819,7 @@ bool Unit::isAnimProgressBound() const{
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
bool result = false;
@ -854,7 +854,7 @@ bool Unit::isBeingBuilt() const{
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return (currSkill->getClass() == scBeBuilt);
@ -872,7 +872,7 @@ bool Unit::isAlly(const Unit *unit) const {
if(unit == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: unit == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return faction->isAlly(unit->getFaction());
@ -882,7 +882,7 @@ bool Unit::isDamaged() const {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return hp < type->getTotalMaxHp(&totalUpgrade);
@ -892,7 +892,7 @@ bool Unit::isInteresting(InterestingUnitType iut) const {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
switch(iut) {
@ -926,12 +926,12 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(this->currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: this->currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(this->currSkill->getClass() == scMove &&
@ -995,7 +995,7 @@ void Unit::setCurrSkill(SkillClass sc) {
if(getType() == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: getType() == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
setCurrSkill(getType()->getFirstStOfClass(sc));
@ -1006,7 +1006,7 @@ void Unit::setTarget(const Unit *unit){
if(unit == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: unit == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//find a free pos in cellmap
@ -1020,7 +1020,7 @@ void Unit::setTarget(const Unit *unit){
void Unit::setPos(const Vec2i &pos, bool clearPathFinder) {
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
throw runtime_error("#3 Invalid path position = " + pos.getString());
throw megaglest_runtime_error("#3 Invalid path position = " + pos.getString());
}
if(clearPathFinder == true && this->unitPath != NULL) {
@ -1041,7 +1041,7 @@ void Unit::setPos(const Vec2i &pos, bool clearPathFinder) {
void Unit::setTargetPos(const Vec2i &targetPos) {
if(map->isInside(targetPos) == false || map->isInsideSurface(map->toSurfCoords(targetPos)) == false) {
throw runtime_error("#4 Invalid path position = " + targetPos.getString());
throw megaglest_runtime_error("#4 Invalid path position = " + targetPos.getString());
}
Vec2i relPos= targetPos - pos;
@ -1119,7 +1119,7 @@ Model *Unit::getCurrentModelPtr() {
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
int currentModelIndexForCurrSkillType = lastModelIndexForCurrSkillType;
@ -1137,7 +1137,7 @@ const Model *Unit::getCurrentModel() {
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
int currentModelIndexForCurrSkillType = lastModelIndexForCurrSkillType;
@ -1180,7 +1180,7 @@ Vec3f Unit::getCurrVector() const{
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return getCurrVectorFlat() + Vec3f(0.f, type->getHeight()/2.f, 0.f);
@ -1527,7 +1527,7 @@ void Unit::born(const CommandType *ct) {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
faction->addStore(type);
@ -1618,7 +1618,7 @@ const CommandType *Unit::computeCommandType(const Vec2i &pos, const Unit *target
const CommandType *commandType= NULL;
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
throw runtime_error("#6 Invalid path position = " + pos.getString());
throw megaglest_runtime_error("#6 Invalid path position = " + pos.getString());
}
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(pos));
@ -1626,7 +1626,7 @@ const CommandType *Unit::computeCommandType(const Vec2i &pos, const Unit *target
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(targetUnit!=NULL){
@ -1662,7 +1662,7 @@ bool Unit::needToUpdate() {
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
bool return_value = false;
@ -1762,7 +1762,7 @@ bool Unit::update() {
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//speed
@ -2070,7 +2070,7 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) {
if(boost == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: boost == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//printf("APPLYING ATTACK BOOST to unit [%s - %d] from unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId());
@ -2184,7 +2184,7 @@ void Unit::deapplyAttackBoost(const AttackBoost *boost, const Unit *source) {
if(boost == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: boost == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//printf("DE-APPLYING ATTACK BOOST START to unit [%s - %d] from unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId());
@ -2276,7 +2276,7 @@ void Unit::tick() {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//if(this->getType()->getName() == "spearman") printf("Unit [%d - %s] start tick hp = %d\n",this->getId(),this->getType()->getName().c_str(),hp);
@ -2381,7 +2381,7 @@ bool Unit::computeEp() {
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//if not enough ep
@ -2397,7 +2397,7 @@ bool Unit::computeEp() {
if(getType() == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: getType() == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(ep > getType()->getTotalMaxEp(&totalUpgrade)){
@ -2413,7 +2413,7 @@ bool Unit::computeEp() {
// if(currSkill == NULL) {
// char szBuf[4096]="";
// sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
// throw runtime_error(szBuf);
// throw megaglest_runtime_error(szBuf);
// }
//
// if(isBeingBuilt() == false) {
@ -2449,7 +2449,7 @@ bool Unit::repair(){
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//increase hp
@ -2485,7 +2485,7 @@ bool Unit::decHp(int i) {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//startDamageParticles
@ -2625,7 +2625,7 @@ void Unit::applyUpgrade(const UpgradeType *upgradeType){
if(upgradeType == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: upgradeType == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(upgradeType->isAffected(type)){
@ -2673,7 +2673,7 @@ bool Unit::morph(const MorphCommandType *mct){
if(mct == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: mct == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const UnitType *morphUnitType= mct->getMorphUnit();
@ -2681,7 +2681,7 @@ bool Unit::morph(const MorphCommandType *mct){
if(morphUnitType == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: morphUnitType == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
Field morphUnitField=fLand;
@ -2724,7 +2724,7 @@ float Unit::computeHeight(const Vec2i &pos) const{
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
//printf("CRASHING FOR UNIT: %d [%s] alive = %d\n",this->getId(),this->getType()->getName().c_str(),this->isAlive());
//abort();
throw runtime_error("#7 Invalid path position = " + pos.getString());
throw megaglest_runtime_error("#7 Invalid path position = " + pos.getString());
}
float height= map->getCell(pos)->getHeight();
@ -2804,7 +2804,7 @@ CommandResult Unit::checkCommand(Command *command) const {
if(command == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: command == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//if not operative or has not command type => fail
@ -2835,7 +2835,7 @@ CommandResult Unit::checkCommand(Command *command) const {
if(command->getCommandType() == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: command->getCommandType() == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
const ProducibleType *produced= command->getCommandType()->getProduced();
@ -2857,7 +2857,7 @@ CommandResult Unit::checkCommand(Command *command) const {
if(builtUnit == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: builtUnit == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(faction->reqsOk(builtUnit) == false) {
@ -2874,7 +2874,7 @@ CommandResult Unit::checkCommand(Command *command) const {
if(uct == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: uct == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(faction->getUpgradeManager()->isUpgradingOrUpgraded(uct->getProducedUpgrade())){
@ -2890,12 +2890,12 @@ void Unit::applyCommand(Command *command){
if(command == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: command == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else if(command->getCommandType() == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: command->getCommandType() == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//check produced
@ -2915,7 +2915,7 @@ void Unit::applyCommand(Command *command){
if(uct == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: uct == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
faction->startUpgrade(uct->getProducedUpgrade());
@ -2927,12 +2927,12 @@ CommandResult Unit::undoCommand(Command *command){
if(command == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: command == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
else if(command->getCommandType() == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: command->getCommandType() == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//return cost
@ -2954,7 +2954,7 @@ CommandResult Unit::undoCommand(Command *command){
if(uct == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: uct == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
faction->cancelUpgrade(uct->getProducedUpgrade());
@ -3194,7 +3194,7 @@ void Unit::setMeetingPos(const Vec2i &meetingPos) {
map->clampPos(this->meetingPos);
if(map->isInside(this->meetingPos) == false || map->isInsideSurface(map->toSurfCoords(this->meetingPos)) == false) {
throw runtime_error("#8 Invalid path position = " + this->meetingPos.getString());
throw megaglest_runtime_error("#8 Invalid path position = " + this->meetingPos.getString());
}
logSynchData(__FILE__,__LINE__);
@ -3221,10 +3221,10 @@ void Unit::exploreCells() {
int teamIndex = this->getTeam();
if(game == NULL) {
throw runtime_error("game == NULL");
throw megaglest_runtime_error("game == NULL");
}
else if(game->getWorld() == NULL) {
throw runtime_error("game->getWorld() == NULL");
throw megaglest_runtime_error("game->getWorld() == NULL");
}
game->getWorld()->exploreCells(newPos, sightRange, teamIndex);
@ -3836,7 +3836,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
newpath = new UnitPath();
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
//Unit *result = new Unit(getNextUnitId(f), newpath, Vec2i(0), ut, f, &map, CardinalDir::NORTH);

View File

@ -117,7 +117,7 @@ void UpgradeManager::cancelUpgrade(const UpgradeType *upgradeType) {
if(iterFind->second >= upgrades.size()) {
char szBuf[1024]="";
sprintf(szBuf,"Error canceling upgrade, iterFind->second >= upgrades.size() - [%d] : [%d]",iterFind->second,(int)upgrades.size());
throw runtime_error("Error canceling upgrade, upgrade not found in upgrade manager");
throw megaglest_runtime_error("Error canceling upgrade, upgrade not found in upgrade manager");
}
int eraseIndex = iterFind->second;
upgrades.erase(upgrades.begin() + eraseIndex);
@ -134,7 +134,7 @@ void UpgradeManager::cancelUpgrade(const UpgradeType *upgradeType) {
}
}
else {
throw runtime_error("Error canceling upgrade, upgrade not found in upgrade manager");
throw megaglest_runtime_error("Error canceling upgrade, upgrade not found in upgrade manager");
}
/*
@ -150,7 +150,7 @@ void UpgradeManager::cancelUpgrade(const UpgradeType *upgradeType) {
upgrades.erase(it);
}
else{
throw runtime_error("Error canceling upgrade, upgrade not found in upgrade manager");
throw megaglest_runtime_error("Error canceling upgrade, upgrade not found in upgrade manager");
}
*/
}
@ -161,7 +161,7 @@ void UpgradeManager::finishUpgrade(const UpgradeType *upgradeType) {
upgrades[iterFind->second]->setState(usUpgraded);
}
else {
throw runtime_error("Error finishing upgrade, upgrade not found in upgrade manager");
throw megaglest_runtime_error("Error finishing upgrade, upgrade not found in upgrade manager");
}
@ -178,7 +178,7 @@ void UpgradeManager::finishUpgrade(const UpgradeType *upgradeType) {
(*it)->setState(usUpgraded);
}
else{
throw runtime_error("Error finishing upgrade, upgrade not found in upgrade manager");
throw megaglest_runtime_error("Error finishing upgrade, upgrade not found in upgrade manager");
}
*/
}

View File

@ -52,7 +52,7 @@ string RequirableType::getReqDesc() const{
string reqString="";
for(int i=0; i<getUnitReqCount(); ++i){
if(getUnitReq(i) == NULL) {
throw runtime_error("getUnitReq(i) == NULL");
throw megaglest_runtime_error("getUnitReq(i) == NULL");
}
reqString+= getUnitReq(i)->getName();
reqString+= "\n";
@ -61,7 +61,7 @@ string RequirableType::getReqDesc() const{
for(int i=0; i<getUpgradeReqCount(); ++i){
if(getUpgradeReq(i) == NULL) {
throw runtime_error("getUpgradeReq(i) == NULL");
throw megaglest_runtime_error("getUpgradeReq(i) == NULL");
}
reqString+= getUpgradeReq(i)->getName();

View File

@ -154,7 +154,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());
throw runtime_error("Error loading units: "+ currentPath + "\n" + e.what());
throw megaglest_runtime_error("Error loading units: "+ currentPath + "\n" + e.what());
}
// b2) load upgrades
@ -169,7 +169,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());
throw runtime_error("Error loading upgrades: "+ currentPath + "\n" + e.what());
throw megaglest_runtime_error("Error loading upgrades: "+ currentPath + "\n" + e.what());
}
string tmppath= currentPath + factionName +".xml";
@ -751,7 +751,7 @@ const UnitType *FactionType::getUnitType(const string &name) const{
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());
}
throw runtime_error("Unit type not found: [" + name + "] in faction type [" + this->name + "]");
throw megaglest_runtime_error("Unit type not found: [" + name + "] in faction type [" + this->name + "]");
}
const UnitType *FactionType::getUnitTypeById(int id) const{
@ -771,7 +771,7 @@ const UnitType *FactionType::getUnitTypeById(int id) const{
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());
}
throw runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]");
throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]");
}
const UpgradeType *FactionType::getUpgradeType(const string &name) const{
@ -791,7 +791,7 @@ const UpgradeType *FactionType::getUpgradeType(const string &name) const{
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());
}
throw runtime_error("Upgrade type not found: [" + name + "] in faction type [" + this->name + "]");
throw megaglest_runtime_error("Upgrade type not found: [" + name + "] in faction type [" + this->name + "]");
}
int FactionType::getStartingResourceAmount(const ResourceType *resourceType) const{

View File

@ -181,7 +181,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading resource type: " + path + "\n" + e.what());
throw megaglest_runtime_error("Error loading resource type: " + path + "\n" + e.what());
}
}
@ -200,7 +200,7 @@ ResourceClass ResourceType::strToRc(const string &s){
if(s=="consumable"){
return rcConsumable;
}
throw runtime_error("Error converting from string ro resourceClass, found: " + s);
throw megaglest_runtime_error("Error converting from string ro resourceClass, found: " + s);
}
void ResourceType::deletePixels() {

View File

@ -333,7 +333,7 @@ void SkillType::loadAttackBoost(const XmlNode *attackBoostsNode, const XmlNode *
else {
char szBuf[4096] = "";
sprintf(szBuf, "Unsupported target [%s] specified for attack boost for skill [%s] in [%s]", targetType.c_str(), name.c_str(), parentLoader.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
attackBoost.boostUpgrade.load(attackBoostNode,attackBoost.name);
@ -419,7 +419,7 @@ void SkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
if(animations.empty() == true) {
char szBuf[4096]="";
sprintf(szBuf,"Error no animations found for skill [%s] for parentLoader [%s]",name.c_str(),parentLoader.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//particles
@ -716,7 +716,7 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
if(attackVar < 0) {
char szBuf[4096]="";
sprintf(szBuf,"The attack skill has an INVALID attack var value which is < 0 [%d] in file [%s]!",attackVar,dir.c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
attackRange= sn->getChild("attack-range")->getAttribute("value")->getIntValue();
@ -744,7 +744,7 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
attackFields[fAir]= true;
}
else{
throw runtime_error("Not a valid field: "+fieldName+": "+ dir);
throw megaglest_runtime_error("Not a valid field: "+fieldName+": "+ dir);
}
}

View File

@ -114,7 +114,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());
throw runtime_error("Error loading Resource Types in: [" + currentPath + "]\n" + e.what());
throw megaglest_runtime_error("Error loading Resource Types in: [" + currentPath + "]\n" + e.what());
}
// give CPU time to update other things to avoid apperance of hanging
@ -183,7 +183,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());
throw runtime_error("Error loading Tech Tree: "+ currentPath + "\n" + e.what());
throw megaglest_runtime_error("Error loading Tech Tree: "+ currentPath + "\n" + e.what());
}
// give CPU time to update other things to avoid apperance of hanging
@ -218,7 +218,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());
throw runtime_error("Error loading Faction Types: "+ currentPath + "\n" + e.what());
throw megaglest_runtime_error("Error loading Faction Types: "+ currentPath + "\n" + e.what());
}
if(techtreeChecksum != NULL) {
@ -296,7 +296,7 @@ FactionType *TechTree::getTypeByName(const string &name) {
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
throw runtime_error("Faction not found: "+name);
throw megaglest_runtime_error("Faction not found: "+name);
}
const FactionType *TechTree::getType(const string &name) const {
@ -306,7 +306,7 @@ const FactionType *TechTree::getType(const string &name) const {
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
throw runtime_error("Faction not found: "+name);
throw megaglest_runtime_error("Faction not found: "+name);
}
const ResourceType *TechTree::getTechResourceType(int i) const{
@ -314,7 +314,7 @@ const ResourceType *TechTree::getTechResourceType(int i) const{
const ResourceType *rt= getResourceType(j);
assert(rt != NULL);
if(rt == NULL) {
throw runtime_error("rt == NULL");
throw megaglest_runtime_error("rt == NULL");
}
if(rt->getResourceNumber() == i && rt->getClass() == rcTech)
return getResourceType(j);
@ -331,7 +331,7 @@ const ResourceType *TechTree::getFirstTechResourceType() const{
return getResourceType(i);
}
throw runtime_error("This tech tree has no resources defined, at least one is required");
throw megaglest_runtime_error("This tech tree has no resources defined, at least one is required");
}
const ResourceType *TechTree::getResourceType(const string &name) const{
@ -342,7 +342,7 @@ const ResourceType *TechTree::getResourceType(const string &name) const{
}
}
throw runtime_error("Resource Type not found: "+name);
throw megaglest_runtime_error("Resource Type not found: "+name);
}
const ArmorType *TechTree::getArmorType(const string &name) const{
@ -352,7 +352,7 @@ const ArmorType *TechTree::getArmorType(const string &name) const{
}
}
throw runtime_error("Armor Type not found: "+name);
throw megaglest_runtime_error("Armor Type not found: "+name);
}
const AttackType *TechTree::getAttackType(const string &name) const{
@ -362,7 +362,7 @@ const AttackType *TechTree::getAttackType(const string &name) const{
}
}
throw runtime_error("Attack Type not found: "+name);
throw megaglest_runtime_error("Attack Type not found: "+name);
}
float TechTree::getDamageMultiplier(const AttackType *att, const ArmorType *art) const{

View File

@ -243,7 +243,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
const XmlNode *rowNode= cellMapNode->getChild("row", i);
string row= rowNode->getAttribute("value")->getRestrictedValue();
if(row.size()!=size){
throw runtime_error("Cellmap row has not the same length as unit size");
throw megaglest_runtime_error("Cellmap row has not the same length as unit size");
}
for(int j=0; j<row.size(); ++j){
cellMap[i*size+j]= row[j]=='0'? false: true;
@ -273,7 +273,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
fields[fAir]= true;
}
else{
throw runtime_error("Not a valid field: "+fieldName+": "+ path);
throw megaglest_runtime_error("Not a valid field: "+fieldName+": "+ path);
}
}
@ -284,7 +284,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
field = fAir;
}
else {
throw runtime_error("Unit has no field: " + path);
throw megaglest_runtime_error("Unit has no field: " + path);
}
//properties
@ -301,7 +301,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
}
}
if(!found) {
throw runtime_error("Unknown property: " + propertyName);
throw megaglest_runtime_error("Unknown property: " + propertyName);
}
}
//damage-particles
@ -601,17 +601,17 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
computeFirstCtOfClass();
if(getFirstStOfClass(scStop)==NULL){
throw runtime_error("Every unit must have at least one stop skill: "+ path);
throw megaglest_runtime_error("Every unit must have at least one stop skill: "+ path);
}
if(getFirstStOfClass(scDie)==NULL){
throw runtime_error("Every unit must have at least one die skill: "+ path);
throw megaglest_runtime_error("Every unit must have at least one die skill: "+ path);
}
}
//Exception handling (conversions and so on);
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading UnitType: " + path + "\n" + 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__);
@ -689,7 +689,7 @@ const AttackCommandType *UnitType::getFirstAttackCommand(Field field) const{
for(int i = 0; i < commandTypes.size(); ++i){
if(commandTypes[i] == NULL) {
throw runtime_error("commandTypes[i] == NULL");
throw megaglest_runtime_error("commandTypes[i] == NULL");
}
//printf("$$$ Unit [%s] i = %d, commandTypes[i] [%s]\n",this->getName().c_str(),(int)i, commandTypes[i]->toString().c_str());
@ -710,7 +710,7 @@ const AttackStoppedCommandType *UnitType::getFirstAttackStoppedCommand(Field fie
for(int i = 0; i < commandTypes.size(); ++i){
if(commandTypes[i] == NULL) {
throw runtime_error("commandTypes[i] == NULL");
throw megaglest_runtime_error("commandTypes[i] == NULL");
}
//printf("$$$ Unit [%s] i = %d, commandTypes[i] [%s]\n",this->getName().c_str(),(int)i, commandTypes[i]->toString().c_str());
@ -776,7 +776,7 @@ Vec2i UnitType::getFirstOccupiedCellInCellMap(Vec2i currentPos) const {
bool UnitType::getCellMapCell(int x, int y, CardinalDir facing) const {
assert(cellMap);
if(cellMap == NULL) {
throw runtime_error("cellMap == NULL");
throw megaglest_runtime_error("cellMap == NULL");
}
//checkItemInVault(&(this->size),this->size);
@ -818,11 +818,11 @@ const SkillType *UnitType::getSkillType(const string &skillName, SkillClass skil
return skillTypes[i];
}
else{
throw runtime_error("Skill \""+skillName+"\" is not of class \""+SkillType::skillClassToStr(skillClass));
throw megaglest_runtime_error("Skill \""+skillName+"\" is not of class \""+SkillType::skillClassToStr(skillClass));
}
}
}
throw runtime_error("No skill named \""+skillName+"\"");
throw megaglest_runtime_error("No skill named \""+skillName+"\"");
}
// ==================== totals ====================
@ -953,7 +953,7 @@ const CommandType *UnitType::getCommandType(int i) const {
if(i >= commandTypes.size()) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] i >= commandTypes.size(), i = %d, commandTypes.size() = %lu",__FILE__,__FUNCTION__,__LINE__,i,(unsigned long)commandTypes.size());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return commandTypes[i];
}

View File

@ -186,7 +186,7 @@ int UpgradeTypeBase::getProdSpeed(const SkillType *st) const {
}
}
else {
throw runtime_error("Unsupported skilltype in getProdSpeed!");
throw megaglest_runtime_error("Unsupported skilltype in getProdSpeed!");
}
return result;
@ -665,7 +665,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading UpgradeType: "+ dir + "\n" +e.what());
throw megaglest_runtime_error("Error loading UpgradeType: "+ dir + "\n" +e.what());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -368,12 +368,12 @@ SurfaceCell *Map::getSurfaceCell(const Vec2i &sPos) const {
SurfaceCell *Map::getSurfaceCell(int sx, int sy) const {
int arrayIndex = sy * surfaceW + sx;
if(arrayIndex < 0 || arrayIndex >= getSurfaceCellArraySize()) {
throw runtime_error("arrayIndex >= getSurfaceCellArraySize(), arrayIndex = " + intToStr(arrayIndex) +
throw megaglest_runtime_error("arrayIndex >= getSurfaceCellArraySize(), arrayIndex = " + intToStr(arrayIndex) +
" surfaceW = " + intToStr(surfaceW) + " surfaceH = " + intToStr(surfaceH) +
" sx: " + intToStr(sx) + " sy: " + intToStr(sy));
}
else if(surfaceCells == NULL) {
throw runtime_error("surfaceCells == NULL");
throw megaglest_runtime_error("surfaceCells == NULL");
}
return &surfaceCells[arrayIndex];
}
@ -390,10 +390,10 @@ Cell *Map::getCell(int x, int y) const {
int arrayIndex = y * w + x;
if(arrayIndex < 0 || arrayIndex >= getCellArraySize()) {
//abort();
throw runtime_error("arrayIndex >= getCellArraySize(), arrayIndex = " + intToStr(arrayIndex) + " w = " + intToStr(w) + " h = " + intToStr(h));
throw megaglest_runtime_error("arrayIndex >= getCellArraySize(), arrayIndex = " + intToStr(arrayIndex) + " w = " + intToStr(w) + " h = " + intToStr(h));
}
else if(cells == NULL) {
throw runtime_error("cells == NULL");
throw megaglest_runtime_error("cells == NULL");
}
return &cells[arrayIndex];
@ -404,11 +404,11 @@ Vec2i Map::getStartLocation(int locationIndex) const {
char szBuf[4096]="";
sprintf(szBuf,"locationIndex >= maxPlayers [%d] [%d]",locationIndex, maxPlayers);
printf("%s\n",szBuf);
//throw runtime_error(szBuf);
//throw megaglest_runtime_error(szBuf);
assert(locationIndex < maxPlayers);
}
else if(startLocations == NULL) {
throw runtime_error("startLocations == NULL");
throw megaglest_runtime_error("startLocations == NULL");
}
return startLocations[locationIndex];
@ -431,15 +431,15 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
MapFileHeader header;
size_t readBytes = fread(&header, sizeof(MapFileHeader), 1, f);
if(readBytes != 1) {
throw runtime_error("Invalid map header detected for file: " + path);
throw megaglest_runtime_error("Invalid map header detected for file: " + path);
}
if(next2Power(header.width) != header.width){
throw runtime_error("Map width is not a power of 2");
throw megaglest_runtime_error("Map width is not a power of 2");
}
if(next2Power(header.height) != header.height){
throw runtime_error("Map height is not a power of 2");
throw megaglest_runtime_error("Map height is not a power of 2");
}
heightFactor= header.heightFactor;
@ -533,13 +533,13 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
else{
if(f) fclose(f);
throw runtime_error("Can't open file");
throw megaglest_runtime_error("Can't open file");
}
fclose(f);
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error loading map: "+ path+ "\n"+ e.what());
throw megaglest_runtime_error("Error loading map: "+ path+ "\n"+ e.what());
}
return mapChecksum;
@ -877,10 +877,10 @@ bool Map::isFreeCells(const Vec2i & pos, int size, Field field) const {
bool Map::isFreeCellsOrHasUnit(const Vec2i &pos, int size, Field field,
const Unit *unit, const UnitType *munit) const {
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
if(munit == NULL) {
throw runtime_error("munit == NULL");
throw megaglest_runtime_error("munit == NULL");
}
for(int i=pos.x; i<pos.x+size; ++i) {
for(int j=pos.y; j<pos.y+size; ++j) {
@ -1255,7 +1255,7 @@ Vec2i Map::computeRefPos(const Selection *selection) const {
Vec2i total= Vec2i(0);
for(int i = 0; i < selection->getCount(); ++i) {
if(selection == NULL || selection->getUnit(i) == NULL) {
throw runtime_error("selection == NULL || selection->getUnit(i) == NULL");
throw megaglest_runtime_error("selection == NULL || selection->getUnit(i) == NULL");
}
total = total + selection->getUnit(i)->getPos();
}
@ -1284,7 +1284,7 @@ Vec2i Map::computeDestPos( const Vec2i &refUnitPos, const Vec2i &unitPos,
std::pair<float,Vec2i> Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut) {
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
std::pair<float,Vec2i> result(-1,Vec2i(0));
@ -1409,7 +1409,7 @@ bool Map::isInUnitTypeCells(const UnitType *ut, const Vec2i &pos,
const Vec2i &testPos) const {
assert(ut != NULL);
if(ut == NULL) {
throw runtime_error("ut == NULL");
throw megaglest_runtime_error("ut == NULL");
}
if(isInside(testPos) && isInsideSurface(toSurfCoords(testPos))) {
@ -1433,7 +1433,7 @@ bool Map::isInUnitTypeCells(const UnitType *ut, const Vec2i &pos,
void Map::putUnitCells(Unit *unit, const Vec2i &pos) {
assert(unit != NULL);
if(unit == NULL) {
throw runtime_error("ut == NULL");
throw megaglest_runtime_error("ut == NULL");
}
bool canPutInCell = true;
@ -1444,7 +1444,7 @@ void Map::putUnitCells(Unit *unit, const Vec2i &pos) {
Vec2i currPos= pos + Vec2i(i, j);
assert(isInside(currPos));
if(isInside(currPos) == false) {
throw runtime_error("isInside(currPos) == false");
throw megaglest_runtime_error("isInside(currPos) == false");
}
if( ut->hasCellMap() == false || ut->getCellMapCell(i, j, unit->getModelFacing())) {
@ -1469,7 +1469,7 @@ void Map::putUnitCells(Unit *unit, const Vec2i &pos) {
// it is likely being created or morphed so we will will log the error
else {
canPutInCell = false;
// throw runtime_error("getCell(currPos)->getUnit(unit->getCurrField()) != NULL");
// throw megaglest_runtime_error("getCell(currPos)->getUnit(unit->getCurrField()) != NULL");
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] ERROR [getCell(currPos)->getUnit(unit->getCurrField()) != NULL] currPos [%s] unit [%s] cell unit [%s]\n",
__FILE__,__FUNCTION__,__LINE__,
currPos.getString().c_str(),
@ -1503,7 +1503,7 @@ void Map::putUnitCells(Unit *unit, const Vec2i &pos) {
void Map::clearUnitCells(Unit *unit, const Vec2i &pos) {
assert(unit != NULL);
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
const UnitType *ut= unit->getType();
@ -1513,7 +1513,7 @@ void Map::clearUnitCells(Unit *unit, const Vec2i &pos) {
Vec2i currPos= pos + Vec2i(i, j);
assert(isInside(currPos));
if(isInside(currPos) == false) {
throw runtime_error("isInside(currPos) == false");
throw megaglest_runtime_error("isInside(currPos) == false");
}
if(ut->hasCellMap() == false || ut->getCellMapCell(i, j, unit->getModelFacing())) {
@ -1522,7 +1522,7 @@ void Map::clearUnitCells(Unit *unit, const Vec2i &pos) {
//assert(getCell(currPos)->getUnit(unit->getCurrField()) == unit || getCell(currPos)->getUnit(unit->getCurrField()) == NULL);
//if(getCell(currPos)->getUnit(unit->getCurrField()) != unit && getCell(currPos)->getUnit(unit->getCurrField()) != NULL) {
// throw runtime_error("getCell(currPos)->getUnit(unit->getCurrField()) != unit");
// throw megaglest_runtime_error("getCell(currPos)->getUnit(unit->getCurrField()) != unit");
//SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] ERROR [getCell(currPos)->getUnit(unit->getCurrField()) != unit] currPos [%s] unit [%s] cell unit [%s]\n",
// __FILE__,__FUNCTION__,__LINE__,
// currPos.getString().c_str(),
@ -1830,7 +1830,7 @@ string Map::getMapPath(const string &mapName, string scenarioDir, bool errorOnNo
if(errorOnNotFound == true) {
//abort();
throw runtime_error("Map not found [" + mapName + "]\nScenario [" + scenarioDir + "]");
throw megaglest_runtime_error("Map not found [" + mapName + "]\nScenario [" + scenarioDir + "]");
}
return "";
@ -1992,7 +1992,7 @@ void Map::loadGame(const XmlNode *rootNode, World *world) {
// string value = tokensExploredValue[k];
// printf("k = %d [%s]\n",k,value.c_str());
// }
// throw runtime_error("tokensExploredValue.size() [" + intToStr(tokensExploredValue.size()) + "] != GameConstants::maxPlayers");
// throw megaglest_runtime_error("tokensExploredValue.size() [" + intToStr(tokensExploredValue.size()) + "] != GameConstants::maxPlayers");
// }
for(unsigned int k = 0; k < tokensExploredValue.size(); ++k) {
string value = tokensExploredValue[k];
@ -2014,7 +2014,7 @@ void Map::loadGame(const XmlNode *rootNode, World *world) {
Tokenize(valueList,tokensVisibleValue,"|");
// if(tokensVisibleValue.size() != GameConstants::maxPlayers) {
// throw runtime_error("tokensVisibleValue.size() [" + intToStr(tokensVisibleValue.size()) + "] != GameConstants::maxPlayers");
// throw megaglest_runtime_error("tokensVisibleValue.size() [" + intToStr(tokensVisibleValue.size()) + "] != GameConstants::maxPlayers");
// }
for(unsigned int k = 0; k < tokensVisibleValue.size(); ++k) {

View File

@ -59,12 +59,12 @@ public:
Cell();
//get
Unit *getUnit(int field) const { if(field >= fieldCount) { throw runtime_error("Invalid field value" + intToStr(field));} return units[field];}
Unit *getUnitWithEmptyCellMap(int field) const { if(field >= fieldCount) { throw runtime_error("Invalid field value" + intToStr(field));} return unitsWithEmptyCellMap[field];}
Unit *getUnit(int field) const { if(field >= fieldCount) { throw megaglest_runtime_error("Invalid field value" + intToStr(field));} return units[field];}
Unit *getUnitWithEmptyCellMap(int field) const { if(field >= fieldCount) { throw megaglest_runtime_error("Invalid field value" + intToStr(field));} return unitsWithEmptyCellMap[field];}
float getHeight() const {return height;}
void setUnit(int field, Unit *unit) { if(field >= fieldCount) { throw runtime_error("Invalid field value" + intToStr(field));} units[field]= unit;}
void setUnitWithEmptyCellMap(int field, Unit *unit) { if(field >= fieldCount) { throw runtime_error("Invalid field value" + intToStr(field));} unitsWithEmptyCellMap[field]= unit;}
void setUnit(int field, Unit *unit) { if(field >= fieldCount) { throw megaglest_runtime_error("Invalid field value" + intToStr(field));} units[field]= unit;}
void setUnitWithEmptyCellMap(int field, Unit *unit) { if(field >= fieldCount) { throw megaglest_runtime_error("Invalid field value" + intToStr(field));} unitsWithEmptyCellMap[field]= unit;}
void setHeight(float height) {this->height= height;}
bool isFree(Field field) const;

View File

@ -12,7 +12,6 @@
#include "scenario.h"
#include <stdexcept>
#include "logger.h"
#include "xml_parser.h"
#include "util.h"
@ -23,7 +22,7 @@
#include "lang.h"
#include "socket.h"
#include "config.h"
#include "platform_util.h"
#include "leak_dumper.h"
using namespace Shared::Xml;
@ -76,7 +75,7 @@ Checksum Scenario::load(const string &path) {
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return scenarioChecksum;

View File

@ -68,7 +68,7 @@ SurfaceAtlas::SurfaceAtlas() {
void SurfaceAtlas::addSurface(SurfaceInfo *si) {
if(si == NULL) {
throw runtime_error("Bad surface info (NULL)");
throw megaglest_runtime_error("Bad surface info (NULL)");
}
//check dimensions
@ -89,7 +89,7 @@ void SurfaceAtlas::addSurface(SurfaceInfo *si) {
Texture2D *t= Renderer::getInstance().newTexture2D(rsGame);
if(t) {
//if(t == NULL) {
// throw runtime_error("Could not create new texture (NULL)");
// throw megaglest_runtime_error("Could not create new texture (NULL)");
//}
t->setWrapMode(Texture::wmClampToEdge);
t->getPixmap()->init(surfaceSize, surfaceSize, 3);
@ -127,7 +127,7 @@ void SurfaceAtlas::checkDimensions(const Pixmap2D *p) {
}
if(p == NULL) {
throw runtime_error("Bad surface texture pixmap (NULL)");
throw megaglest_runtime_error("Bad surface texture pixmap (NULL)");
}
else if(surfaceSize == -1) {
surfaceSize= p->getW();
@ -136,7 +136,7 @@ void SurfaceAtlas::checkDimensions(const Pixmap2D *p) {
else if(p->getW() != surfaceSize || p->getH() != surfaceSize) {
char szBuf[1024]="";
sprintf(szBuf,"Bad surface texture dimensions, expected surfaceSize = %d, texture w = %d, h = %d",surfaceSize,p->getW(),p->getH());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}

View File

@ -359,7 +359,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
//Exception handling (conversions and so on);
catch(const exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error: " + path + "\n" + e.what());
throw megaglest_runtime_error("Error: " + path + "\n" + e.what());
}
}

View File

@ -80,7 +80,7 @@ void UnitUpdater::init(Game *game){
routePlanner = world->getRoutePlanner();
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
}
@ -230,7 +230,7 @@ void UnitUpdater::updateUnit(Unit *unit) {
newpath = new UnitPath();
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
Unit *spawned= new Unit(world->getNextUnitId(unit->getFaction()), newpath,
@ -425,7 +425,7 @@ void UnitUpdater::updateMove(Unit *unit, int frameIndex) {
tsValue = routePlanner->findPath(unit, pos);
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -515,7 +515,7 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
tsValue = routePlanner->findPath(unit, pos);
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -723,7 +723,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
tsValue = routePlanner->findPathToBuildSite(unit, ut, command->getPos(), command->getFacing());
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] tsValue = %d\n",__FILE__,__FUNCTION__,__LINE__,tsValue);
@ -743,7 +743,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
//if arrived destination
assert(ut);
if(ut == NULL) {
throw runtime_error("ut == NULL");
throw megaglest_runtime_error("ut == NULL");
}
bool canOccupyCell = false;
@ -756,7 +756,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
canOccupyCell = map->canOccupy(command->getPos(), ut->getField(), ut, command->getFacing());
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] canOccupyCell = %d\n",__FILE__,__FUNCTION__,__LINE__,canOccupyCell);
@ -774,7 +774,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
newpath = new UnitPath();
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
Vec2i buildPos = command->getPos();
@ -785,7 +785,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
builtUnit->create();
if(builtUnitType->hasSkillClass(scBeBuilt) == false) {
throw runtime_error("Unit [" + builtUnitType->getName() + "] has no be_built skill, producer was [" + intToStr(unit->getId()) + " - " + unit->getType()->getName() + "].");
throw megaglest_runtime_error("Unit [" + builtUnitType->getName() + "] has no be_built skill, producer was [" + intToStr(unit->getId()) + " - " + unit->getType()->getName() + "].");
}
builtUnit->setCurrSkill(scBeBuilt);
@ -803,7 +803,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
world->getCartographer()->updateMapMetrics(builtUnit->getPos(), builtUnit->getType()->getSight());
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
command->setUnit(builtUnit);
@ -956,7 +956,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
canHarvestDestPos = map->isResourceNear(unit->getPos(), unit->getType()->getSize(), r->getType(), targetPos);
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -985,7 +985,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
unit->setLoadType(r->getType());
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -1022,7 +1022,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
}
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -1045,7 +1045,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
canHarvestDestPos = map->isResourceNear(unit->getPos(), unit->getType()->getSize(), r->getType(), targetPos);
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if (canHarvestDestPos == true) {
@ -1071,7 +1071,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
unit->setLoadType(r->getType());
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
}
}
@ -1112,7 +1112,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
}
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
}
@ -1164,7 +1164,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
tsValue = routePlanner->findPathToStore(unit, store);
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -1293,7 +1293,7 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
world->getCartographer()->onResourceDepleted(Map::toSurfCoords(unit->getTargetPos()), rt);
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
//printf("\n\n#6\n\n");
@ -1659,7 +1659,7 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
}
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] ts = %d\n",__FILE__,__FUNCTION__,__LINE__,ts);
@ -1795,7 +1795,7 @@ void UnitUpdater::updateProduce(Unit *unit, int frameIndex) {
newpath = new UnitPath();
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
produced= new Unit(world->getNextUnitId(unit->getFaction()), newpath, Vec2i(0), pct->getProducedUnit(), unit->getFaction(), world->getMap(), CardinalDir::NORTH);
@ -1903,7 +1903,7 @@ void UnitUpdater::updateMorph(Unit *unit, int frameIndex) {
needMapUpdate = unit->getType()->isMobile() != mct->getMorphUnit()->isMobile();
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
//finish the command
@ -1922,7 +1922,7 @@ void UnitUpdater::updateMorph(Unit *unit, int frameIndex) {
}
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
scriptManager->onUnitCreated(unit);
@ -1969,7 +1969,7 @@ void UnitUpdater::updateSwitchTeam(Unit *unit, int frameIndex) {
// tsValue = routePlanner->findPath(unit, pos);
// break;
// default:
// throw runtime_error("detected unsupported pathfinder type!");
// throw megaglest_runtime_error("detected unsupported pathfinder type!");
// }
//
// if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -2033,13 +2033,13 @@ void UnitUpdater::hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &t
void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attacked, float distance) {
if(attacker == NULL) {
throw runtime_error("attacker == NULL");
throw megaglest_runtime_error("attacker == NULL");
}
if(ast == NULL) {
throw runtime_error("ast == NULL");
throw megaglest_runtime_error("ast == NULL");
}
if(attacked == NULL) {
throw runtime_error("attacked == NULL");
throw megaglest_runtime_error("attacked == NULL");
}
//get vars
@ -2076,7 +2076,7 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
}
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
attacked->setCauseOfDeath(ucodAttacked);

View File

@ -384,7 +384,7 @@ void World::updateAllFactionUnits() {
// for(int i = 0; i < factionCount; ++i) {
// Faction *faction = getFaction(i);
// if(faction == NULL) {
// throw runtime_error("faction == NULL");
// throw megaglest_runtime_error("faction == NULL");
// }
//
// // Sort units by command groups
@ -396,7 +396,7 @@ void World::updateAllFactionUnits() {
for(int i = 0; i < factionCount; ++i) {
Faction *faction = getFaction(i);
if(faction == NULL) {
throw runtime_error("faction == NULL");
throw megaglest_runtime_error("faction == NULL");
}
faction->clearUnitsPathfinding();
}
@ -405,7 +405,7 @@ void World::updateAllFactionUnits() {
for(int i = 0; i < factionCount; ++i) {
Faction *faction = getFaction(i);
if(faction == NULL) {
throw runtime_error("faction == NULL");
throw megaglest_runtime_error("faction == NULL");
}
faction->signalWorkerThread(frameCount);
}
@ -420,7 +420,7 @@ void World::updateAllFactionUnits() {
for(int i = 0; i < factionCount; ++i) {
Faction *faction = getFaction(i);
if(faction == NULL) {
throw runtime_error("faction == NULL");
throw megaglest_runtime_error("faction == NULL");
}
if(faction->isWorkerThreadSignalCompleted(frameCount) == false) {
workThreadsFinished = false;
@ -441,14 +441,14 @@ void World::updateAllFactionUnits() {
for(int i = 0; i < factionCount; ++i) {
Faction *faction = getFaction(i);
if(faction == NULL) {
throw runtime_error("faction == NULL");
throw megaglest_runtime_error("faction == NULL");
}
int unitCount = faction->getUnitCount();
for(int j = 0; j < unitCount; ++j) {
Unit *unit = faction->getUnit(j);
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
unitUpdater.updateUnit(unit);
@ -475,7 +475,7 @@ void World::underTakeDeadFactionUnits() {
if(factionIdxToTick == -1 || factionIdxToTick == i) {
Faction *faction = getFaction(i);
if(faction == NULL) {
throw runtime_error("faction == NULL");
throw megaglest_runtime_error("faction == NULL");
}
int unitCount = faction->getUnitCount();
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] factionIdxToTick = %d, i = %d, unitCount = %d\n",__FILE__,__FUNCTION__,__LINE__,factionIdxToTick,i,unitCount);
@ -484,7 +484,7 @@ void World::underTakeDeadFactionUnits() {
Unit *unit= faction->getUnit(j);
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
if(unit->getToBeUndertaken() == true) {
@ -507,7 +507,7 @@ void World::updateAllFactionConsumableCosts() {
for(int j = 0; j < factionCount; ++j) {
Faction *faction = getFaction(j);
if(faction == NULL) {
throw runtime_error("faction == NULL");
throw megaglest_runtime_error("faction == NULL");
}
faction->applyCostsOnInterval(rt);
@ -632,14 +632,14 @@ void World::tick() {
if(factionIdxToTick == -1 || i == factionIdxToTick) {
Faction *faction = getFaction(i);
if(faction == NULL) {
throw runtime_error("faction == NULL");
throw megaglest_runtime_error("faction == NULL");
}
int unitCount = faction->getUnitCount();
for(int j = 0; j < unitCount; ++j) {
Unit *unit = faction->getUnit(j);
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
unit->tick();
@ -654,7 +654,7 @@ void World::tick() {
if(factionIdxToTick == -1 || k == factionIdxToTick) {
Faction *faction= getFaction(k);
if(faction == NULL) {
throw runtime_error("faction == NULL");
throw megaglest_runtime_error("faction == NULL");
}
//for each resource
@ -699,7 +699,7 @@ Unit* World::findUnitById(int id) const {
const UnitType* World::findUnitTypeById(const FactionType* factionType, int id) {
if(factionType == NULL) {
throw runtime_error("factionType == NULL");
throw megaglest_runtime_error("factionType == NULL");
}
for(int i= 0; i < factionType->getUnitTypeCount(); ++i) {
const UnitType *unitType = factionType->getUnitType(i);
@ -713,7 +713,7 @@ const UnitType* World::findUnitTypeById(const FactionType* factionType, int id)
//looks for a place for a unit around a start location, returns true if succeded
bool World::placeUnit(const Vec2i &startLoc, int radius, Unit *unit, bool spaciated) {
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
bool freeSpace=false;
@ -747,7 +747,7 @@ bool World::placeUnit(const Vec2i &startLoc, int radius, Unit *unit, bool spacia
//clears a unit old position from map and places new position
void World::moveUnitCells(Unit *unit) {
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
Vec2i newPos= unit->getTargetPos();
@ -790,7 +790,7 @@ Unit *World::nearestStore(const Vec2i &pos, int factionIndex, const ResourceType
Unit *currUnit= NULL;
if(factionIndex >= getFactionCount()) {
throw runtime_error("factionIndex >= getFactionCount()");
throw megaglest_runtime_error("factionIndex >= getFactionCount()");
}
for(int i=0; i < getFaction(factionIndex)->getUnitCount(); ++i) {
@ -808,7 +808,7 @@ Unit *World::nearestStore(const Vec2i &pos, int factionIndex, const ResourceType
bool World::toRenderUnit(const Unit *unit, const Quad2i &visibleQuad) const {
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
//a unit is rendered if it is in a visible cell or is attacking a unit in a visible cell
@ -817,7 +817,7 @@ bool World::toRenderUnit(const Unit *unit, const Quad2i &visibleQuad) const {
bool World::toRenderUnit(const Unit *unit) const {
if(unit == NULL) {
throw runtime_error("unit == NULL");
throw megaglest_runtime_error("unit == NULL");
}
if(showWorldForPlayer(thisFactionIndex) == true) {
@ -856,7 +856,7 @@ void World::morphToUnit(int unitId,const string &morphName,bool ignoreRequiremen
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
unit->setIgnoreCheckCommand(false);
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
if(cr == crSuccess) {
@ -884,7 +884,7 @@ void World::createUnit(const string &unitName, int factionIndex, const Vec2i &po
Faction* faction= factions[factionIndex];
if(faction->getIndex() != factionIndex) {
throw runtime_error("faction->getIndex() != factionIndex");
throw megaglest_runtime_error("faction->getIndex() != factionIndex");
}
const FactionType* ft= faction->getType();
@ -899,7 +899,7 @@ void World::createUnit(const string &unitName, int factionIndex, const Vec2i &po
newpath = new UnitPath();
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
Unit* unit= new Unit(getNextUnitId(faction), newpath, pos, ut, faction, &map, CardinalDir::NORTH);
@ -914,13 +914,13 @@ void World::createUnit(const string &unitName, int factionIndex, const Vec2i &po
else {
delete unit;
unit = NULL;
throw runtime_error("Unit cant be placed");
throw megaglest_runtime_error("Unit cant be placed");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit created for unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str());
}
else {
throw runtime_error("Invalid faction index in createUnitAtPosition: " + intToStr(factionIndex));
throw megaglest_runtime_error("Invalid faction index in createUnitAtPosition: " + intToStr(factionIndex));
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -933,7 +933,7 @@ void World::giveResource(const string &resourceName, int factionIndex, int amoun
faction->incResourceAmount(rt, amount);
}
else {
throw runtime_error("Invalid faction index in giveResource: " + intToStr(factionIndex));
throw megaglest_runtime_error("Invalid faction index in giveResource: " + intToStr(factionIndex));
}
}
@ -962,7 +962,7 @@ vector<int> World::getUnitsForFaction(int factionIndex,const string& commandType
vector<int> units;
if(factionIndex < 0 || factionIndex > getFactionCount()) {
throw runtime_error("Invalid faction index in getUnitsForFaction: " + intToStr(factionIndex));
throw megaglest_runtime_error("Invalid faction index in getUnitsForFaction: " + intToStr(factionIndex));
}
Faction *faction = getFaction(factionIndex);
if(faction != NULL) {
@ -1016,18 +1016,18 @@ void World::givePositionCommand(int unitId, const string &commandName, const Vec
cc= ccAttack;
}
else {
throw runtime_error("Invalid position commmand: " + commandName);
throw megaglest_runtime_error("Invalid position commmand: " + commandName);
}
if(unit->getType()->getFirstCtOfClass(cc) == NULL) {
throw runtime_error("Invalid commmand: [" + commandName + "] for unit: [" + unit->getType()->getName() + "] id [" + intToStr(unit->getId()) + "]");
throw megaglest_runtime_error("Invalid commmand: [" + commandName + "] for unit: [" + unit->getType()->getName() + "] id [" + intToStr(unit->getId()) + "]");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] cc = %d Unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,cc,unit->getFullName().c_str());
unit->giveCommand(new Command( unit->getType()->getFirstCtOfClass(cc), pos ));
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
else {
throw runtime_error("Invalid unitId index in givePositionCommand: " + intToStr(unitId) + " commandName = " + commandName);
throw megaglest_runtime_error("Invalid unitId index in givePositionCommand: " + intToStr(unitId) + " commandName = " + commandName);
}
}
@ -1044,15 +1044,15 @@ void World::giveAttackCommand(int unitId, int unitToAttackId) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
else {
throw runtime_error("Invalid ct in giveAttackCommand: " + intToStr(unitId) + " unitToAttackId = " + intToStr(unitToAttackId));
throw megaglest_runtime_error("Invalid ct in giveAttackCommand: " + intToStr(unitId) + " unitToAttackId = " + intToStr(unitToAttackId));
}
}
else {
throw runtime_error("Invalid unitToAttackId index in giveAttackCommand: " + intToStr(unitId) + " unitToAttackId = " + intToStr(unitToAttackId));
throw megaglest_runtime_error("Invalid unitToAttackId index in giveAttackCommand: " + intToStr(unitId) + " unitToAttackId = " + intToStr(unitToAttackId));
}
}
else {
throw runtime_error("Invalid unitId index in giveAttackCommand: " + intToStr(unitId) + " unitToAttackId = " + intToStr(unitToAttackId));
throw megaglest_runtime_error("Invalid unitId index in giveAttackCommand: " + intToStr(unitId) + " unitToAttackId = " + intToStr(unitToAttackId));
}
}
@ -1078,7 +1078,7 @@ void World::giveProductionCommand(int unitId, const string &producedName) {
}
}
else {
throw runtime_error("Invalid unitId index in giveProductionCommand: " + intToStr(unitId) + " producedName = " + producedName);
throw megaglest_runtime_error("Invalid unitId index in giveProductionCommand: " + intToStr(unitId) + " producedName = " + producedName);
}
}
@ -1107,7 +1107,7 @@ void World::giveAttackStoppedCommand(int unitId, const string &itemName, bool ig
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
unit->setIgnoreCheckCommand(false);
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
@ -1118,7 +1118,7 @@ void World::giveAttackStoppedCommand(int unitId, const string &itemName, bool ig
}
}
else {
throw runtime_error("Invalid unitId index in giveAttackStoppedCommand: " + intToStr(unitId) + " itemName = " + itemName);
throw megaglest_runtime_error("Invalid unitId index in giveAttackStoppedCommand: " + intToStr(unitId) + " itemName = " + itemName);
}
}
@ -1180,7 +1180,7 @@ void World::moveToUnit(int unitId, int destUnitId) {
}
}
else {
throw runtime_error("Invalid unitId index in followUnit: " + intToStr(unitId));
throw megaglest_runtime_error("Invalid unitId index in followUnit: " + intToStr(unitId));
}
}
@ -1239,7 +1239,7 @@ void World::giveUpgradeCommand(int unitId, const string &upgradeName) {
}
}
else {
throw runtime_error("Invalid unitId index in giveUpgradeCommand: " + intToStr(unitId) + " upgradeName = " + upgradeName);
throw megaglest_runtime_error("Invalid unitId index in giveUpgradeCommand: " + intToStr(unitId) + " upgradeName = " + upgradeName);
}
}
@ -1251,7 +1251,7 @@ int World::getResourceAmount(const string &resourceName, int factionIndex) {
return faction->getResource(rt)->getAmount();
}
else {
throw runtime_error("Invalid faction index in giveResource: " + intToStr(factionIndex) + " resourceName = " + resourceName);
throw megaglest_runtime_error("Invalid faction index in giveResource: " + intToStr(factionIndex) + " resourceName = " + resourceName);
}
}
@ -1263,14 +1263,14 @@ Vec2i World::getStartLocation(int factionIndex) {
else {
printf("\n=================================================\n%s\n",game->getGameSettings()->toString().c_str());
throw runtime_error("Invalid faction index in getStartLocation: " + intToStr(factionIndex) + " : " + intToStr(factions.size()));
throw megaglest_runtime_error("Invalid faction index in getStartLocation: " + intToStr(factionIndex) + " : " + intToStr(factions.size()));
}
}
Vec2i World::getUnitPosition(int unitId) {
Unit* unit= findUnitById(unitId);
if(unit == NULL) {
throw runtime_error("Can not find unit to get position unitId = " + intToStr(unitId));
throw megaglest_runtime_error("Can not find unit to get position unitId = " + intToStr(unitId));
}
return unit->getPos();
}
@ -1278,7 +1278,7 @@ Vec2i World::getUnitPosition(int unitId) {
void World::setUnitPosition(int unitId, Vec2i pos) {
Unit* unit= findUnitById(unitId);
if(unit == NULL) {
throw runtime_error("Can not find unit to set position unitId = " + intToStr(unitId));
throw megaglest_runtime_error("Can not find unit to set position unitId = " + intToStr(unitId));
}
unit->setPos(pos,true);
}
@ -1286,7 +1286,7 @@ void World::setUnitPosition(int unitId, Vec2i pos) {
int World::getUnitFactionIndex(int unitId) {
Unit* unit= findUnitById(unitId);
if(unit == NULL) {
throw runtime_error("Can not find Faction unit to get position unitId = " + intToStr(unitId));
throw megaglest_runtime_error("Can not find Faction unit to get position unitId = " + intToStr(unitId));
}
return unit->getFactionIndex();
}
@ -1305,7 +1305,7 @@ int World::getUnitCount(int factionIndex) {
return count;
}
else {
throw runtime_error("Invalid faction index in getUnitCount: " + intToStr(factionIndex));
throw megaglest_runtime_error("Invalid faction index in getUnitCount: " + intToStr(factionIndex));
}
}
@ -1323,7 +1323,7 @@ int World::getUnitCountOfType(int factionIndex, const string &typeName) {
return count;
}
else {
throw runtime_error("Invalid faction index in getUnitCountOfType: " + intToStr(factionIndex));
throw megaglest_runtime_error("Invalid faction index in getUnitCountOfType: " + intToStr(factionIndex));
}
}
@ -1341,7 +1341,7 @@ void World::initCells(bool fogOfWar) {
SurfaceCell *sc= map.getSurfaceCell(i, j);
if(sc == NULL) {
throw runtime_error("sc == NULL");
throw megaglest_runtime_error("sc == NULL");
}
if(sc->getObject()!=NULL){
sc->getObject()->initParticles();
@ -1376,16 +1376,16 @@ void World::initSplattedTextures() {
SurfaceCell *sc11= map.getSurfaceCell(i+1, j+1);
if(sc00 == NULL) {
throw runtime_error("sc00 == NULL");
throw megaglest_runtime_error("sc00 == NULL");
}
if(sc10 == NULL) {
throw runtime_error("sc10 == NULL");
throw megaglest_runtime_error("sc10 == NULL");
}
if(sc01 == NULL) {
throw runtime_error("sc01 == NULL");
throw megaglest_runtime_error("sc01 == NULL");
}
if(sc11 == NULL) {
throw runtime_error("sc11 == NULL");
throw megaglest_runtime_error("sc11 == NULL");
}
tileset.addSurfTex( sc00->getSurfaceType(),
@ -1406,11 +1406,11 @@ void World::initFactionTypes(GameSettings *gs) {
Logger::getInstance().add(Lang::getInstance().get("LogScreenGameLoadingFactionTypes","",true), true);
if(gs == NULL) {
throw runtime_error("gs == NULL");
throw megaglest_runtime_error("gs == NULL");
}
if(gs->getFactionCount() > map.getMaxPlayers()) {
throw runtime_error("This map only supports "+intToStr(map.getMaxPlayers())+" players");
throw megaglest_runtime_error("This map only supports "+intToStr(map.getMaxPlayers())+" players");
}
//create stats
@ -1431,7 +1431,7 @@ void World::initFactionTypes(GameSettings *gs) {
for(int i=0; i < factions.size(); ++i) {
FactionType *ft= techTree->getTypeByName(gs->getFactionTypeName(i));
if(ft == NULL) {
throw runtime_error("ft == NULL");
throw megaglest_runtime_error("ft == NULL");
}
factions[i]->init(ft, gs->getFactionControl(i), techTree, game, i, gs->getTeam(i),
gs->getStartLocationIndex(i), i==thisFactionIndex,
@ -1547,7 +1547,7 @@ void World::initUnitsForScenario() {
string unitName = unit->getType()->getName();
delete unit;
unit = NULL;
throw runtime_error("Unit: " + unitName + " can't be placed, this error is caused because there\nis not enough room to put all units near their start location.\nmake a better/larger map. Faction: #" + intToStr(i) + " name: " + ft->getName());
throw megaglest_runtime_error("Unit: " + unitName + " can't be placed, this error is caused because there\nis not enough room to put all units near their start location.\nmake a better/larger map. Faction: #" + intToStr(i) + " name: " + ft->getName());
}
if (unit->getType()->hasSkillClass(scBeBuilt)) {
@ -1580,7 +1580,7 @@ void World::placeUnitAtLocation(const Vec2i &location, int radius, Unit *unit, b
char szBuf[4096]="";
sprintf(szBuf,"Unit: [%s] can't be placed, this error is caused because there\nis not enough room to put all units near their start location.\nmake a better/larger map. Faction: #%d name: [%s]",
unitName.c_str(),unit->getFactionIndex(),unit->getFaction()->getType()->getName().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if (unit->getType()->hasSkillClass(scBeBuilt)) {
map.flatternTerrain(unit);
@ -1617,7 +1617,7 @@ void World::initUnits() {
newpath = new UnitPath();
break;
default:
throw runtime_error("detected unsupported pathfinder type!");
throw megaglest_runtime_error("detected unsupported pathfinder type!");
}
Unit *unit= new Unit(getNextUnitId(f), newpath, Vec2i(0), ut, f, &map, CardinalDir::NORTH);
@ -1632,7 +1632,7 @@ void World::initUnits() {
// string unitName = unit->getType()->getName();
// delete unit;
// unit = NULL;
// throw runtime_error("Unit: " + unitName + " can't be placed, this error is caused because there\nis not enough room to put all units near their start location.\nmake a better/larger map. Faction: #" + intToStr(i) + " name: " + ft->getName());
// throw megaglest_runtime_error("Unit: " + unitName + " can't be placed, this error is caused because there\nis not enough room to put all units near their start location.\nmake a better/larger map. Faction: #" + intToStr(i) + " name: " + ft->getName());
// }
// if (unit->getType()->hasSkillClass(scBeBuilt)) {
// map.flatternTerrain(unit);
@ -1750,7 +1750,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex) {
if(map.isInsideSurface(currPos)){
SurfaceCell *sc= map.getSurfaceCell(currPos);
if(sc == NULL) {
throw runtime_error("sc == NULL");
throw megaglest_runtime_error("sc == NULL");
}
//explore

View File

@ -72,6 +72,7 @@ IF(BUILD_MEGAGLEST_MAP_EDITOR)
${GLEST_LIB_INCLUDE_ROOT}map
${GLEST_MAIN_INCLUDE_ROOT}facilities
${GLEST_MAIN_INCLUDE_ROOT}game
${GLEST_LIB_INCLUDE_ROOT}xml/rapidxml
${GLEST_MAIN_INCLUDE_ROOT}global)
IF(WANT_STREFLOP)

View File

@ -1559,7 +1559,7 @@ bool App::OnInit() {
int App::MainLoop() {
try {
//throw runtime_error("test");
//throw megaglest_runtime_error("test");
return wxApp::MainLoop();
}
catch (const exception &e) {

View File

@ -150,7 +150,7 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
ifstream file(filepath.c_str(), ios::in | ios::binary);
#endif
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
throw runtime_error("[#1] Could not open file " + filepath);
throw megaglest_runtime_error("[#1] Could not open file " + filepath);
}
for (typename vector<FileReader<T> const *>::const_iterator i = readers->begin(); i != readers->end(); ++i) {
T* ret = NULL;
@ -192,9 +192,9 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
#if defined(WIN32) && !defined(__MINGW32__)
DWORD error = GetLastError();
throw runtime_error("[#2] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " [" + filepath + "]");
throw megaglest_runtime_error("[#2] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " [" + filepath + "]");
#else
throw runtime_error("[#2] Could not open file [" + filepath + "]");
throw megaglest_runtime_error("[#2] Could not open file [" + filepath + "]");
#endif
}
for (typename vector<FileReader<T> const *>::const_iterator i = readers->begin(); i != readers->end(); ++i) {
@ -239,7 +239,7 @@ T* FileReader<T>::readPath(const string& filepath) {
T* ret = readFromFileReaders(&(getFileReaders()), filepath); //Try all other
if (ret == NULL) {
std::cerr << "ERROR #1 - Could not parse filepath: " << filepath << std::endl;
throw runtime_error(string("Could not parse ") + filepath + " as object of type " + typeid(T).name());
throw megaglest_runtime_error(string("Could not parse ") + filepath + " as object of type " + typeid(T).name());
}
return ret;
}
@ -264,7 +264,7 @@ T* FileReader<T>::readPath(const string& filepath, T* object) {
std::cerr << "ERROR #2 - Could not parse filepath: " << filepath << std::endl;
ret = readFromFileReaders(&(getLowPriorityFileReaders()), filepath); //Try to get dummy file
if (ret == NULL) {
throw runtime_error(string("Could not parse ") + filepath + " as object of type " + typeid(T).name());
throw megaglest_runtime_error(string("Could not parse ") + filepath + " as object of type " + typeid(T).name());
}
}
return ret;
@ -329,7 +329,7 @@ T* FileReader<T>::read(const string& filepath) const {
ifstream file(filepath.c_str(), ios::in | ios::binary);
#endif
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
throw runtime_error("[#3] Could not open file " + filepath);
throw megaglest_runtime_error("[#3] Could not open file " + filepath);
}
T* ret = read(file,filepath);
file.close();
@ -354,7 +354,7 @@ T* FileReader<T>::read(const string& filepath, T* object) const {
ifstream file(filepath.c_str(), ios::in | ios::binary);
#endif
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
throw runtime_error("[#4] Could not open file " + filepath);
throw megaglest_runtime_error("[#4] Could not open file " + filepath);
}
T* ret = read(file,filepath,object);
file.close();

View File

@ -0,0 +1,26 @@
#ifndef _SHARED_D3D9_D3D9UTIL_H_
#define _SHARED_D3D9_D3D9UTIL_H_
#include <d3d9.h>
#include <string>
#include <stdexcept>
#define D3DCALL(X) checkResult(X, #X);
using std::string;
using std::runtime_error;
namespace Shared{ namespace Graphics{ namespace D3d9{
string d3dErrorToStr(HRESULT result);
inline void checkResult(HRESULT result, const string &functionCall){
if(result!=D3D_OK){
throw megaglest_runtime_error("Direct3D Error\nCode: " + d3dErrorToStr(result) + "\nFunction: " + functionCall);
}
}
}}}//end namespace
#endif

View File

@ -18,6 +18,7 @@
#include <string>
#include "conversion.h"
#include "gl_wrap.h"
#include "platform_util.h"
#include "leak_dumper.h"
using std::runtime_error;
@ -62,8 +63,8 @@ void inline _assertGl(const char *file, int line, GLenum *forceErrorNumber = NUL
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[4096]="";
sprintf(szBuf,"OpenGL error #%d [0x%X] : [%s] at file: [%s], line: %d",error,error,errorString,file,line);
//throw runtime_error("OpenGL error #" + intToStr(error) + " : " + string(errorString) + " at file: " + string(file) + ", line " + intToStr(line));
throw runtime_error(szBuf);
//throw megaglest_runtime_error("OpenGL error #" + intToStr(error) + " : " + string(errorString) + " at file: " + string(file) + ", line " + intToStr(line));
throw megaglest_runtime_error(szBuf);
//}
}

View File

@ -146,7 +146,7 @@ public:
virtual uint32 getCRC() { return pixmap.getCRC()->getSum(); }
SDL_Surface* CreateSDLSurface(bool newPixelData) const;
std::pair<SDL_Surface*,unsigned char*> CreateSDLSurface(bool newPixelData) const;
};
// =====================================================

View File

@ -17,6 +17,7 @@
#include <map>
#include <string>
#include <stdexcept>
#include "platform_util.h"
#include "leak_dumper.h"
using namespace std;
@ -69,7 +70,7 @@ protected:
safeMutex.ReleaseLock();
}
catch(const std::exception &ex) {
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
}
@ -80,7 +81,7 @@ protected:
safeMutex.ReleaseLock();
}
catch(const std::exception &ex) {
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
}
// If this is the first access we return a default object of the type

View File

@ -464,7 +464,7 @@ int mainSetup(int argc, char **argv) {
if(knownArgCount != GAME_ARG_END) {
char szBuf[1024]="";
sprintf(szBuf,"Internal arg count mismatch knownArgCount = %d, GAME_ARG_END = %d",knownArgCount,GAME_ARG_END);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true ||

View File

@ -22,12 +22,20 @@ using std::exception;
namespace Shared { namespace Platform {
class megaglest_runtime_error : public runtime_error {
public:
megaglest_runtime_error(const string& __arg);
};
// =====================================================
// class PlatformExceptionHandler
// =====================================================
class PlatformExceptionHandler {
public:
static string application_binary;
static string getStackTrace();
virtual ~PlatformExceptionHandler() {}
void install(string dumpFileName) {}
virtual void handle()=0;

View File

@ -25,7 +25,7 @@
//#include "util.h"
#include <vector>
#include "types.h"
#include "leak_dumper.h"
//#include "leak_dumper.h"
// =====================================================
// class Thread

View File

@ -12,7 +12,7 @@
#define _SHARED_PLATFORM_TYPES_H_
#include <SDL_types.h>
#include "leak_dumper.h"
//#include "leak_dumper.h"
namespace Shared{ namespace Platform{

View File

@ -28,13 +28,18 @@ LPWSTR Ansi2WideString(LPCSTR lpaszString);
std::string utf8_encode(const std::wstring wstr);
std::wstring utf8_decode(const std::string str);
class megaglest_runtime_error : public runtime_error {
public:
megaglest_runtime_error(const string& __arg);
};
// =====================================================
// class PlatformExceptionHandler
// =====================================================
LONG WINAPI UnhandledExceptionFilter2(struct _EXCEPTION_POINTERS *ExceptionInfo);
class PlatformExceptionHandler{
class PlatformExceptionHandler {
private:
static PlatformExceptionHandler *thisPointer;
@ -43,6 +48,9 @@ private:
string dumpFileName;
public:
static string application_binary;
static string getStackTrace();
void install(string dumpFileName);
virtual void handle()=0;
static string codeToStr(DWORD code);

View File

@ -15,6 +15,7 @@
#include <map>
#include <string>
#include <stdexcept>
#include "platform_util.h"
#include "leak_dumper.h"
using std::map;
@ -72,7 +73,7 @@ public:
T *newInstance(string classId){
Factories::iterator it= factories.find(classId);
if(it == factories.end()){
throw runtime_error("Unknown class identifier: " + classId);
throw megaglest_runtime_error("Unknown class identifier: " + classId);
}
return static_cast<T*>(it->second->newInstance());
}

View File

@ -18,110 +18,324 @@
#ifdef SL_LEAK_DUMP
#include <new>
//#include <memory>
#include <cstdlib>
// START - Special includes because the use a special new operator that we cannot override
#include <string>
#include "rapidxml.hpp"
#include <xercesc/dom/DOM.hpp>
// END - Special includes because the use a special new operator that we cannot override
#include <memory>
#include <cstdio>
//#include <cstddef>
#include <cstdlib>
#include "thread.h"
using Shared::Platform::Mutex;
// START - For gcc backtrace
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
#include <execinfo.h>
#include <cxxabi.h>
#include <signal.h>
#endif
// END - For gcc backtrace
using namespace std;
//including this header in any file of a project will cause all
//leaks to be dumped into leak_dump.txt, but only allocations that
//leaks to be dumped into leak_dump.txt, but only allocations that
//occurred in a file where this header is included will have
//file and line number
struct AllocInfo{
static bool want_full_leak_stacktrace = true;
static bool want_full_leak_stacktrace_line_numbers = false;
struct AllocInfo {
private:
static bool application_binary_initialized;
public:
inline static string &get_application_binary() {
static string application_binary = "";
return application_binary;
}
int line;
const char *file;
size_t bytes;
void *ptr;
bool free;
bool freetouse;
bool array;
bool inuse;
string stack;
AllocInfo();
AllocInfo(void* ptr, const char* file, int line, size_t bytes, bool array);
inline AllocInfo()
: ptr(0), file(""), line(-1), bytes(0), array(false), freetouse(false), inuse(false), stack("") {
}
inline AllocInfo(void* ptr, const char* file, int line, string stacktrace, size_t bytes, bool array)
: ptr(ptr), file(file), line(line), bytes(bytes), array(array), freetouse(false), inuse(true), stack(stacktrace) {
}
#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
inline static int getFileAndLine(void *address, char *file, size_t flen) {
int line=-1;
if(want_full_leak_stacktrace_line_numbers == true && AllocInfo::get_application_binary() != "") {
const int maxbufSize = 4096;
char buf[maxbufSize+1]="";
// prepare command to be executed
// our program need to be passed after the -e parameter
//sprintf (buf, "/usr/bin/addr2line -C -e ./a.out -f -i %lx", addr);
sprintf(buf, "addr2line -C -e %s -f -i %p",AllocInfo::get_application_binary().c_str(),address);
FILE* f = popen (buf, "r");
if (f == NULL) {
perror (buf);
return 0;
}
// get function name
char *ret = fgets (buf, maxbufSize, f);
if(ret == NULL) {
pclose(f);
return 0;
}
// get file and line
ret = fgets (buf, maxbufSize, f);
if(ret == NULL) {
pclose(f);
return 0;
}
if(strlen(buf) > 0 && buf[0] != '?') {
//int l;
char *p = buf;
// file name is until ':'
while(*p != 0 && *p != ':') {
p++;
}
*p++ = 0;
// after file name follows line number
strcpy (file , buf);
sscanf (p,"%d", &line);
}
else {
strcpy (file,"unknown");
line = 0;
}
pclose(f);
}
return line;
}
#endif
inline static string getStackTrace() {
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
if(want_full_leak_stacktrace == true) {
string errMsg = "\nStack Trace:\n";
//errMsg += "To find line #'s use:\n";
//errMsg += "readelf --debug-dump=decodedline %s | egrep 0xaddress-of-stack\n";
const size_t max_depth = 6;
void *stack_addrs[max_depth];
size_t stack_depth = backtrace(stack_addrs, max_depth);
char **stack_strings = backtrace_symbols(stack_addrs, stack_depth);
//for (size_t i = 1; i < stack_depth; i++) {
// errMsg += string(stack_strings[i]) + "\n";
//}
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(stack_depth > 0) {
char szBuf[8096]="";
for(size_t i = 1; i < stack_depth; i++) {
void *lineAddress = stack_addrs[i]; //getStackAddress(stackIndex);
size_t sz = 8096; // just a guess, template names will go much wider
char *function = static_cast<char *>(malloc(sz));
char *begin = 0;
char *end = 0;
// find the parentheses and address offset surrounding the mangled name
for (char *j = stack_strings[i]; *j; ++j) {
if (*j == '(') {
begin = j;
}
else if (*j == '+') {
end = j;
}
}
if (begin && end) {
*begin++ = '\0';
*end = '\0';
// found our mangled name, now in [begin, end)
int status;
char *ret = abi::__cxa_demangle(begin, function, &sz, &status);
if (ret) {
// return value may be a realloc() of the input
function = ret;
}
else {
// demangling failed, just pretend it's a C function with no args
strncpy(function, begin, sz);
strncat(function, "()", sz);
function[sz-1] = '\0';
}
//fprintf(out, " %s:%s\n", stack.strings[i], function);
sprintf(szBuf,"%s:%s address [%p]",stack_strings[i],function,lineAddress);
}
else {
// didn't find the mangled name, just print the whole line
//fprintf(out, " %s\n", stack.strings[i]);
sprintf(szBuf,"%s address [%p]",stack_strings[i],lineAddress);
}
errMsg += string(szBuf);
if(want_full_leak_stacktrace_line_numbers == true && AllocInfo::get_application_binary() != "") {
char file[8096]="";
int line = getFileAndLine(lineAddress, file, 8096);
if(line >= 0) {
char lineBuf[1024]="";
sprintf(lineBuf,"%d",line);
errMsg += " line: " + string(lineBuf);
}
}
errMsg += "\n";
free(function);
}
}
free(stack_strings); // malloc()ed by backtrace_symbols
//printf("%s",errMsg.c_str());
return errMsg;
}
else {
static string empty = "";
return empty;
}
#else
static string empty = "";
return empty;
#endif
}
};
// =====================================================
// class AllocRegistry
// =====================================================
class AllocRegistry{
class AllocRegistry {
private:
static const unsigned maxAllocs= 40000;
static const size_t maxAllocs= 100000;
Mutex *mutex;
private:
AllocRegistry();
inline AllocRegistry() {
mutex = getMutex();
string value = AllocInfo::get_application_binary();
reset();
}
static Mutex * getMutex() {
static Mutex mymutex;
return &mymutex;
}
private:
AllocInfo allocs[maxAllocs]; //array to store allocation info
int allocCount; //allocations
size_t allocBytes; //bytes allocated
int nonMonitoredCount;
size_t allocBytes; //bytes allocated
int nonMonitoredCount;
size_t nonMonitoredBytes;
int nextFreeIndex;
public:
~AllocRegistry();
static AllocRegistry &getInstance() {
static AllocRegistry allocRegistry;
return allocRegistry;
}
static AllocRegistry &getInstance();
inline void reset() {
allocCount= 0;
allocBytes= 0;
nonMonitoredCount= 0;
nonMonitoredBytes= 0;
nextFreeIndex = 0;
for(int i = 0; i < maxAllocs; ++i) {
allocs[i].freetouse = true;
allocs[i].inuse = false;
}
}
void allocate(AllocInfo info);
void deallocate(void* ptr, bool array);
void reset();
void deallocate(void* ptr, bool array,const char* file, int line);
//void reset();
void dump(const char *path);
};
//if an allocation ocurrs in a file where "leaks_dumper.h" is not included
//this operator new is called and file and line will be unknown
void * operator new (size_t bytes) {
inline void * operator new (size_t bytes) {
void *ptr= malloc(bytes);
AllocRegistry::getInstance().allocate(AllocInfo(ptr, "unknown", 0, bytes, false));
AllocRegistry::getInstance().allocate(AllocInfo(ptr, "unknown", 0, "", bytes, false));
return ptr;
}
void operator delete(void *ptr){
AllocRegistry::getInstance().deallocate(ptr, false);
inline void operator delete(void *ptr) {
AllocRegistry::getInstance().deallocate(ptr, false, "unknown", 0);
free(ptr);
}
void * operator new[](size_t bytes){
inline void * operator new[](size_t bytes) {
void *ptr= malloc(bytes);
AllocRegistry::getInstance().allocate(AllocInfo(ptr, "unknown", 0, bytes, true));
AllocRegistry::getInstance().allocate(AllocInfo(ptr, "unknown", 0, "", bytes, true));
return ptr;
}
void operator delete [](void *ptr){
AllocRegistry::getInstance().deallocate(ptr, true);
inline void operator delete [](void *ptr) {
AllocRegistry::getInstance().deallocate(ptr, true, "unknown", 0);
free(ptr);
}
//if an allocation ocurrs in a file where "leaks_dumper.h" is included
//this operator new is called and file and line will be known
void * operator new (size_t bytes, char* file, int line){
inline void * operator new (size_t bytes, const char* file, int line, string stack) {
void *ptr= malloc(bytes);
AllocRegistry::getInstance().allocate(AllocInfo(ptr, file, line, bytes, false));
AllocRegistry::getInstance().allocate(AllocInfo(ptr, file, line, stack, bytes, false));
return ptr;
}
void operator delete(void *ptr, char* file, int line){
AllocRegistry::getInstance().deallocate(ptr, false);
inline void operator delete(void *ptr, const char* file, int line) {
AllocRegistry::getInstance().deallocate(ptr, false, file, line);
free(ptr);
}
void * operator new[](size_t bytes, char* file, int line){
inline void * operator new[](size_t bytes, const char* file, int line,string stack) {
void *ptr= malloc(bytes);
AllocRegistry::getInstance().allocate(AllocInfo(ptr, file, line, bytes, true));
AllocRegistry::getInstance().allocate(AllocInfo(ptr, file, line, stack, bytes, true));
return ptr;
}
void operator delete [](void *ptr, char* file, int line){
AllocRegistry::getInstance().deallocate(ptr, true);
inline void operator delete [](void *ptr, const char* file, int line) {
AllocRegistry::getInstance().deallocate(ptr, true, file, line);
free(ptr);
}
#define new new(__FILE__, __LINE__)
#define new new(__FILE__, __LINE__,AllocInfo::getStackTrace())
//#define new new(__FILE__, __LINE__,"")
#endif
#endif

View File

@ -81,13 +81,13 @@ Pixmap2D* BMPReader::read(ifstream& in, const string& path, Pixmap2D* ret) const
BitmapFileHeader fileHeader;
in.read((char*)&fileHeader, sizeof(BitmapFileHeader));
if(fileHeader.type1!='B' || fileHeader.type2!='M'){
throw runtime_error(path +" is not a bitmap");
throw megaglest_runtime_error(path +" is not a bitmap");
}
//read info header
BitmapInfoHeader infoHeader;
in.read((char*)&infoHeader, sizeof(BitmapInfoHeader));
if(infoHeader.bitCount!=24){
throw runtime_error(path+" is not a 24 bit bitmap");
throw megaglest_runtime_error(path+" is not a 24 bit bitmap");
}
int h= infoHeader.height;
int w= infoHeader.width;

View File

@ -71,21 +71,21 @@ Pixmap3D* TGAReader3D::read(ifstream& in, const string& path, Pixmap3D* ret) con
TargaFileHeader fileHeader;
in.read((char*)&fileHeader, sizeof(TargaFileHeader));
if (!in.good()) {
throw runtime_error(path + " could not be read");
throw megaglest_runtime_error(path + " could not be read");
}
//check that we can load this tga file
if(fileHeader.idLength!=0){
throw runtime_error(path + ": id field is not 0");
throw megaglest_runtime_error(path + ": id field is not 0");
}
if(fileHeader.dataTypeCode!=tgaUncompressedRgb && fileHeader.dataTypeCode!=tgaUncompressedBw){
throw 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");
}
//check bits per pixel
if(fileHeader.bitsPerPixel!=8 && fileHeader.bitsPerPixel!=24 && fileHeader.bitsPerPixel!=32){
throw 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");
}
const int h = fileHeader.height;
@ -170,21 +170,21 @@ Pixmap2D* TGAReader::read(ifstream& in, const string& path, Pixmap2D* ret) const
TargaFileHeader fileHeader;
in.read((char*)&fileHeader, sizeof(TargaFileHeader));
if (!in.good()) {
throw runtime_error(path + " could not be read");
throw megaglest_runtime_error(path + " could not be read");
}
//check that we can load this tga file
if(fileHeader.idLength!=0){
throw runtime_error(path + ": id field is not 0");
throw megaglest_runtime_error(path + ": id field is not 0");
}
if(fileHeader.dataTypeCode!=tgaUncompressedRgb && fileHeader.dataTypeCode!=tgaUncompressedBw){
throw 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");
}
//check bits per pixel
if(fileHeader.bitsPerPixel!=8 && fileHeader.bitsPerPixel!=24 && fileHeader.bitsPerPixel!=32){
throw 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");
}
const int h = fileHeader.height;

View File

@ -0,0 +1,73 @@
#include "context_d3d9.h"
#include <cassert>
#include <stdexcept>
#include "d3d9_util.h"
#include "leak_dumper.h"
using namespace std;
namespace Shared{ namespace Graphics{ namespace D3d9{
// ===============================================
// class ContextD3d9
// ===============================================
ContextD3d9::ContextD3d9(){
windowed= true;
hardware= true;
}
void ContextD3d9::init(){
//create object
d3dObject= Direct3DCreate9(D3D_SDK_VERSION);
if(d3dObject==NULL){
throw megaglest_runtime_error("Direct3DCreate9==NULL");
}
//present parameters
memset(&d3dPresentParameters, 0, sizeof(d3dPresentParameters));
d3dPresentParameters.Windowed = TRUE;
d3dPresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dPresentParameters.BackBufferFormat = D3DFMT_A8R8G8B8;
d3dPresentParameters.EnableAutoDepthStencil= TRUE;
d3dPresentParameters.AutoDepthStencilFormat= D3DFMT_D24X8;
d3dPresentParameters.PresentationInterval= D3DPRESENT_INTERVAL_IMMEDIATE;
//create device
D3DCALL(d3dObject->CreateDevice(
D3DADAPTER_DEFAULT,
hardware? D3DDEVTYPE_HAL: D3DDEVTYPE_REF,
GetActiveWindow(),
hardware? D3DCREATE_HARDWARE_VERTEXPROCESSING: D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dPresentParameters,
&d3dDevice));
//get caps
D3DCALL(d3dDevice->GetDeviceCaps(&caps));
}
void ContextD3d9::end(){
D3DCALL(d3dDevice->Release());
D3DCALL(d3dObject->Release());
}
void ContextD3d9::makeCurrent(){
}
void ContextD3d9::swapBuffers(){
D3DCALL(d3dDevice->Present(NULL, NULL, NULL, NULL));
}
void ContextD3d9::reset(){
d3dPresentParameters.BackBufferWidth= 0;
d3dPresentParameters.BackBufferHeight= 0;
D3DCALL(d3dDevice->Reset(&d3dPresentParameters));
}
}}}//end namespace

View File

@ -0,0 +1,38 @@
#include "font_d3d9.h"
#include <stdexcept>
#include <d3d9.h>
#include "graphics_interface.h"
#include "context_d3d9.h"
#include "leak_dumper.h"
using namespace std;
namespace Shared{ namespace Graphics{ namespace D3d9{
// ===============================================
// class Font2DD3d9
// ===============================================
void Font2DD3d9::init(){
GraphicsInterface &gi= GraphicsInterface::getInstance();
IDirect3DDevice9 *d3dDevice= static_cast<ContextD3d9*>(gi.getCurrentContext())->getD3dDevice();
HFONT hFont=CreateFont(size, 0, 0, 0, width, 0, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, DEFAULT_PITCH, type.c_str());
HRESULT result= D3DXCreateFont(d3dDevice, hFont, &d3dFont);
if(result!=D3D_OK){
throw megaglest_runtime_error("FontD3d9::init() -> Can't create D3D font");
}
DeleteObject(hFont);
}
void Font2DD3d9::end(){
d3dFont->Release();
}
}}}//end namespace

View File

@ -46,7 +46,7 @@ void ShaderProgramD3d9::setUniform(const string &name, int value){
HRESULT vsResult= d3dVsConstantTable->SetInt(d3dDevice, vsHandle, value);
HRESULT psResult= d3dPsConstantTable->SetInt(d3dDevice, psHandle, value);
if(vsResult!=D3D_OK && psResult!=D3D_OK){
throw runtime_error("Error setting shader uniform: "+string(name));
throw megaglest_runtime_error("Error setting shader uniform: "+string(name));
}
}
@ -56,7 +56,7 @@ void ShaderProgramD3d9::setUniform(const string &name, float value){
HRESULT vsResult= d3dVsConstantTable->SetFloat(d3dDevice, vsHandle, value);
HRESULT psResult= d3dPsConstantTable->SetFloat(d3dDevice, psHandle, value);
if(vsResult!=D3D_OK && psResult!=D3D_OK){
throw runtime_error("Error setting shader uniform: "+string(name));
throw megaglest_runtime_error("Error setting shader uniform: "+string(name));
}
}
@ -77,12 +77,12 @@ void ShaderProgramD3d9::setUniform(const string &name, const Vec4f &value){
HRESULT vsResult= d3dVsConstantTable->SetVector(d3dDevice, vsHandle, &v);
HRESULT psResult= d3dPsConstantTable->SetVector(d3dDevice, psHandle, &v);
if(vsResult!=D3D_OK && psResult!=D3D_OK){
throw runtime_error("Error setting shader uniform: "+string(name));
throw megaglest_runtime_error("Error setting shader uniform: "+string(name));
}
}
void ShaderProgramD3d9::setUniform(const string &name, const Matrix3f &value){
throw runtime_error("Not implemented");
throw megaglest_runtime_error("Not implemented");
}
void ShaderProgramD3d9::setUniform(const string &name, const Matrix4f &value){
@ -94,7 +94,7 @@ void ShaderProgramD3d9::setUniform(const string &name, const Matrix4f &value){
HRESULT vsResult= d3dVsConstantTable->SetMatrix(d3dDevice, vsHandle, &m);
HRESULT psResult= d3dPsConstantTable->SetMatrix(d3dDevice, psHandle, &m);
if(vsResult!=D3D_OK && psResult!=D3D_OK){
throw runtime_error("Error setting shader uniform: "+string(name));
throw megaglest_runtime_error("Error setting shader uniform: "+string(name));
}
}
@ -107,7 +107,7 @@ void ShaderProgramD3d9::setUniform(const string &name, const Matrix4f &value){
if(result==D3D_OK)
d3dDevice->SetTexture(d3dDesc.RegisterIndex, d3dTexture);
else
throw runtime_error("Error setting shader uniform sampler: "+string(name));
throw megaglest_runtime_error("Error setting shader uniform sampler: "+string(name));
}
bool ShaderD3d9::isUniform(char *name){

View File

@ -0,0 +1,192 @@
#include "texture_d3d9.h"
#include <stdexcept>
#include <cassert>
#include "graphics_interface.h"
#include "context_d3d9.h"
#include "d3d9_util.h"
#include "leak_dumper.h"
using namespace std;
using namespace Shared::Graphics;
namespace Shared{ namespace Graphics{ namespace D3d9{
// ===============================================
// class Texture2DD3d9
// ===============================================
D3DFORMAT toFormatD3d(Texture::Format format, int components){
switch(format){
case Texture::fAuto:
switch(components){
case 1:
return D3DFMT_L8;
case 3:
return D3DFMT_X8R8G8B8;
case 4:
return D3DFMT_A8R8G8B8;
default:
assert(false);
return D3DFMT_A8R8G8B8;
}
break;
case Texture::fLuminance:
return D3DFMT_L8;
case Texture::fAlpha:
return D3DFMT_A8;
case Texture::fRgb:
return D3DFMT_X8R8G8B8;
case Texture::fRgba:
return D3DFMT_A8R8G8B8;
default:
assert(false);
return D3DFMT_A8R8G8B8;
}
}
void fillPixels(uint8 *texturePixels, const Pixmap2D *pixmap){
for(int i=0; i<pixmap->getW(); ++i){
for(int j=0; j<pixmap->getH(); ++j){
int k= j*pixmap->getW()+i;
Vec4<uint8> pixel;
pixmap->getPixel(i, j, pixel.ptr());
switch(pixmap->getComponents()){
case 1:
texturePixels[k]= pixel.x;
break;
case 3:
texturePixels[k*4]= pixel.z;
texturePixels[k*4+1]= pixel.y;
texturePixels[k*4+2]= pixel.x;
break;
case 4:
texturePixels[k*4]= pixel.z;
texturePixels[k*4+1]= pixel.y;
texturePixels[k*4+2]= pixel.x;
texturePixels[k*4+3]= pixel.w;
break;
default:
assert(false);
}
}
}
}
void Texture2DD3d9::init(Filter textureFilter, int maxAnisotropy){
if(!inited){
//get device
GraphicsInterface &gi= GraphicsInterface::getInstance();
ContextD3d9 *context= static_cast<ContextD3d9*>(gi.getCurrentContext());
IDirect3DDevice9 *d3dDevice= context->getD3dDevice();
bool mipmapCaps= (context->getCaps()->TextureCaps & D3DPTEXTURECAPS_MIPCUBEMAP) != 0;
bool autogenMipmap= mipmapCaps && mipmap;
int w= pixmapInit? pixmap.getW(): defaultSize;
int h= pixmapInit? pixmap.getH(): defaultSize;
//create texture
D3DCALL(d3dDevice->CreateTexture(
w,
h,
autogenMipmap? 0: 1,
autogenMipmap? D3DUSAGE_AUTOGENMIPMAP: 0,
toFormatD3d(format, pixmap.getComponents()),
D3DPOOL_MANAGED,
&d3dTexture,
NULL));
if(pixmapInit){
//lock
D3DLOCKED_RECT lockedRect;
D3DCALL(d3dTexture->LockRect(0, &lockedRect, NULL, 0));
//copy
fillPixels(reinterpret_cast<uint8*>(lockedRect.pBits), &pixmap);
//unlock
D3DCALL(d3dTexture->UnlockRect(0));
}
inited= true;
}
}
void Texture2DD3d9::end(){
if(inited){
d3dTexture->Release();
}
}
// ===============================================
// class TextureCubeD3d9
// ===============================================
void TextureCubeD3d9::init(Filter textureFilter, int maxAnisotropy){
//get device
if(!inited){
GraphicsInterface &gi= GraphicsInterface::getInstance();
ContextD3d9 *context= static_cast<ContextD3d9*>(gi.getCurrentContext());
IDirect3DDevice9 *d3dDevice= context->getD3dDevice();
const Pixmap2D *face0= pixmap.getFace(0);
int l= pixmapInit? face0->getW(): defaultSize;
int components= face0->getComponents();
//check dimensions and face components
if(pixmapInit){
for(int i=0; i<6; ++i){
const Pixmap2D *currentFace= pixmap.getFace(i);
if(currentFace->getW()!=l || currentFace->getH()!=l){
throw megaglest_runtime_error("Can't create Direct3D cube texture: dimensions don't agree");
}
if(currentFace->getComponents()!=components){
throw megaglest_runtime_error("Can't create Direct3D cube texture: components don't agree");
}
}
}
bool mipmapCaps= (context->getCaps()->TextureCaps & D3DPTEXTURECAPS_MIPCUBEMAP) != 0;
bool autogenMipmap= mipmapCaps && mipmap;
//create texture
D3DCALL(d3dDevice->CreateCubeTexture(
l,
autogenMipmap? 0: 1,
autogenMipmap? D3DUSAGE_AUTOGENMIPMAP: 0,
toFormatD3d(format, components),
D3DPOOL_MANAGED,
&d3dCubeTexture,
NULL));
if(pixmapInit){
for(int i=0; i<6; ++i){
//lock
D3DLOCKED_RECT lockedRect;
D3DCALL(d3dCubeTexture->LockRect(static_cast<D3DCUBEMAP_FACES>(i), 0, &lockedRect, NULL, 0));
//copy
fillPixels(reinterpret_cast<uint8*>(lockedRect.pBits), pixmap.getFace(i));
//unlock
D3DCALL(d3dCubeTexture->UnlockRect(static_cast<D3DCUBEMAP_FACES>(i), 0));
}
}
inited= true;
}
}
void TextureCubeD3d9::end(){
if(inited){
d3dCubeTexture->Release();
}
}
}}}//end namespace

View File

@ -30,7 +30,7 @@ using namespace Shared::Graphics::Gl;
#include "util.h"
#include "platform_common.h"
#include "platform_util.h"
#include "leak_dumper.h"
using namespace std;
@ -130,7 +130,7 @@ float FontMetrics::getTextWidth(const string &str) {
for(unsigned int i=0; i< str.size() && (int)i < Font::charCount; ++i){
if(str[i] >= Font::charCount) {
string sError = "str[i] >= Font::charCount, [" + str + "] i = " + intToStr(i);
throw runtime_error(sError);
throw megaglest_runtime_error(sError);
}
//Treat 2 byte characters as spaces
if(str[i] < 0) {

View File

@ -40,7 +40,7 @@ int TextFTGL::faceResolution = 72;
//====================================================================
TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
//throw runtime_error("FTGL!");
//throw megaglest_runtime_error("FTGL!");
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc",0);
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/arphic/uming.ttc",0); // Chinese
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/arphic/ukai.ttc",0); // Chinese
@ -70,7 +70,7 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("3D font [%s]\n",fontFile);
}
else {
throw runtime_error("font render type not set to a known value!");
throw megaglest_runtime_error("font render type not set to a known value!");
}
if(ftFont->Error()) {
@ -78,7 +78,7 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
delete ftFont; ftFont = NULL;
free((void*)fontFile);
fontFile = NULL;
throw runtime_error(string("FTGL: error loading font: ") + string(fontFile));
throw megaglest_runtime_error(string("FTGL: error loading font: ") + string(fontFile));
}
free((void*)fontFile);
fontFile = NULL;
@ -95,19 +95,19 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//ftFont->UseDisplayList(false);
//ftFont->CharMap(ft_encoding_gb2312);
//ftFont->CharMap(ft_encoding_big5);
if(ftFont->CharMap(ft_encoding_unicode) == false) {
throw runtime_error("FTGL: error setting encoding");
throw megaglest_runtime_error("FTGL: error setting encoding");
}
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error setting encoding, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -147,7 +147,7 @@ void TextFTGL::init(string fontName, string fontFamilyName, int fontSize) {
//printf("3D font [%s]\n",fontFile);
}
else {
throw runtime_error("font render type not set to a known value!");
throw megaglest_runtime_error("font render type not set to a known value!");
}
if(ftFont->Error()) {
@ -155,7 +155,7 @@ void TextFTGL::init(string fontName, string fontFamilyName, int fontSize) {
delete ftFont; ftFont = NULL;
free((void*)fontFile);
fontFile = NULL;
throw runtime_error("FTGL: error loading font");
throw megaglest_runtime_error("FTGL: error loading font");
}
free((void*)fontFile);
fontFile = NULL;
@ -174,19 +174,19 @@ void TextFTGL::init(string fontName, string fontFamilyName, int fontSize) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//ftFont->UseDisplayList(false);
//ftFont->CharMap(ft_encoding_gb2312);
//ftFont->CharMap(ft_encoding_big5);
if(ftFont->CharMap(ft_encoding_unicode) == false) {
throw runtime_error("FTGL: error setting encoding");
throw megaglest_runtime_error("FTGL: error setting encoding");
}
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error setting encoding, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
// Create a string containing common characters
@ -203,7 +203,7 @@ void TextFTGL::init(string fontName, string fontFamilyName, int fontSize) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error advancing(a), #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -219,7 +219,7 @@ void TextFTGL::SetFaceSize(int value) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error setting face size, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
@ -249,7 +249,7 @@ void TextFTGL::Render(const char* str, const int len) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error trying to render, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
}
@ -266,7 +266,7 @@ float TextFTGL::Advance(const char* str, const int len) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error trying to advance(b), #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return result;
@ -351,7 +351,7 @@ float TextFTGL::LineHeight(const char* str, const int len) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error trying to get lineheight, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return result;
@ -396,7 +396,7 @@ float TextFTGL::LineHeight(const wchar_t* str, const int len) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error trying to get lineheight, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return result;
@ -413,7 +413,7 @@ void TextFTGL::Render(const wchar_t* str, const int len) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error trying to render, #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
}
@ -423,7 +423,7 @@ float TextFTGL::Advance(const wchar_t* str, const int len) {
if(ftFont->Error()) {
char szBuf[1024]="";
sprintf(szBuf,"FTGL: error trying to advance(c), #%d",ftFont->Error());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
return result;

View File

@ -163,7 +163,7 @@ void ModelRendererGl::renderMesh(Mesh *mesh) {
if(texture != NULL && renderTextures) {
if(lastTexture != texture->getHandle()){
//assert(glIsTexture(texture->getHandle()));
//throw runtime_error("glIsTexture(texture->getHandle()) == false for texture: " + texture->getPath());
//throw megaglest_runtime_error("glIsTexture(texture->getHandle()) == false for texture: " + texture->getPath());
if(glIsTexture(texture->getHandle()) == GL_TRUE) {
glBindTexture(GL_TEXTURE_2D, texture->getHandle());
lastTexture= texture->getHandle();

View File

@ -169,7 +169,7 @@ int getGlProjectionMatrixStackDepth() {
void checkGlExtension(const char *extensionName) {
if(!isGlExtensionSupported(extensionName)){
throw runtime_error("OpenGL extension not supported: " + string(extensionName));
throw megaglest_runtime_error("OpenGL extension not supported: " + string(extensionName));
}
}

View File

@ -162,7 +162,7 @@ void ShaderProgramGl::bindAttribute(const string &name, int index){
GLint ShaderProgramGl::getLocation(const string &name){
GLint location= glGetUniformLocationARB(handle, name.c_str());
if(location==-1){
throw runtime_error("Can't locate uniform: "+ name);
throw megaglest_runtime_error("Can't locate uniform: "+ name);
}
return location;
}

View File

@ -486,7 +486,7 @@ bool TextureGl::supports_FBO_RBO() {
void TextureGl::setup_FBO_RBO() {
if(getTextureWidth() < 0 || getTextureHeight() < 0) {
throw runtime_error("getTextureWidth() < 0 || getTextureHeight() < 0");
throw megaglest_runtime_error("getTextureWidth() < 0 || getTextureHeight() < 0");
}
// Need some work to get extensions properly working in Windows (use Glew lib)
@ -689,11 +689,11 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy) {
//
if(error != 0) {
//throw runtime_error("Error building texture 1D mipmaps");
//throw megaglest_runtime_error("Error building texture 1D mipmaps");
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";
sprintf(szBuf,"Error building texture 1D mipmaps, returned: %d [%s] for [%s] w = %d, glCompressionFormat = %d",error,errorString,pixmap.getPath().c_str(),pixmap.getW(),glCompressionFormat);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
else {
@ -722,11 +722,11 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy) {
//
if(error != GL_NO_ERROR) {
//throw runtime_error("Error creating texture 1D");
//throw megaglest_runtime_error("Error creating texture 1D");
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";
sprintf(szBuf,"Error creating texture 1D, returned: %d [%s] (%X) [%s] w = %d, glCompressionFormat = %d",error,errorString,error,pixmap.getPath().c_str(),pixmap.getW(),glCompressionFormat);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
inited= true;
@ -858,11 +858,11 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) {
//
if(error != GL_NO_ERROR) {
//throw runtime_error("Error building texture 2D mipmaps");
//throw megaglest_runtime_error("Error building texture 2D mipmaps");
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";
sprintf(szBuf,"Error building texture 2D mipmaps [%s], returned: %d [%s] for [%s] w = %d, h = %d, glCompressionFormat = %d",this->path.c_str(),error,errorString,(pixmap.getPath() != "" ? pixmap.getPath().c_str() : this->path.c_str()),pixmap.getW(),pixmap.getH(),glCompressionFormat);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
else {
@ -925,13 +925,13 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) {
//
//throw runtime_error("TEST!");
//throw megaglest_runtime_error("TEST!");
if(error != GL_NO_ERROR) {
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";
sprintf(szBuf,"Error creating texture 2D [%s], returned: %d [%s] (%X) [%s] w = %d, h = %d, glInternalFormat = %d, glFormat = %d, glCompressionFormat = %d",this->path.c_str(),error,errorString,error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),glInternalFormat,glFormat,glCompressionFormat);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
inited= true;
@ -1037,11 +1037,11 @@ void Texture3DGl::init(Filter filter, int maxAnisotropy) {
//
if(error != GL_NO_ERROR) {
//throw runtime_error("Error creating texture 3D");
//throw megaglest_runtime_error("Error creating texture 3D");
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";
sprintf(szBuf,"Error creating texture 3D, returned: %d [%s] (%X) [%s] w = %d, h = %d, d = %d, glCompressionFormat = %d",error,errorString,error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),pixmap.getD(),glCompressionFormat);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
inited= true;
@ -1178,11 +1178,11 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) {
//
if(error != GL_NO_ERROR) {
//throw runtime_error("Error building texture cube mipmaps");
//throw megaglest_runtime_error("Error building texture cube mipmaps");
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";
sprintf(szBuf,"Error building texture cube mipmaps, returned: %d [%s] for [%s] w = %d, h = %d, glCompressionFormat = %d",error,errorString,currentPixmap->getPath().c_str(),currentPixmap->getW(),currentPixmap->getH(),glCompressionFormat);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
else {
@ -1231,11 +1231,11 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) {
//
if(error != GL_NO_ERROR) {
//throw runtime_error("Error creating texture cube");
//throw megaglest_runtime_error("Error creating texture cube");
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";
sprintf(szBuf,"Error creating texture cube, returned: %d [%s] (%X) [%s] w = %d, h = %d, glCompressionFormat = %d",error,errorString,error,currentPixmap->getPath().c_str(),currentPixmap->getW(),currentPixmap->getH(),glCompressionFormat);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}

View File

@ -156,7 +156,7 @@ void ShaderProgramGl::bindAttribute(const string &name, int index){
GLint ShaderProgramGl::getLocation(const string &name){
GLint location= glGetUniformLocationARB(handle, name.c_str());
if(location==-1){
throw runtime_error("Can't locate uniform: "+ name);
throw megaglest_runtime_error("Can't locate uniform: "+ name);
}
return location;
}

View File

@ -18,6 +18,7 @@
#include "conversion.h"
#include "util.h"
#include <stdexcept>
#include "platform_util.h"
#include "leak_dumper.h"
using namespace std;
@ -81,7 +82,7 @@ void InterpolationData::updateVertices(float t, bool cycle) {
}
//assert(t>=0.0f && t<=1.0f);
if(t < 0.0f || t > 1.0f) {
throw runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t) + "]");
throw megaglest_runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t) + "]");
assert(t >= 0.f && t <= 1.f);
}
@ -141,7 +142,7 @@ void InterpolationData::updateVertices(float t, bool cycle) {
void InterpolationData::updateNormals(float t, bool cycle){
if(t < 0.0f || t > 1.0f) {
throw runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t) + "]");
throw megaglest_runtime_error("t < 0.0f || t > 1.0f t = [" + floatToStr(t) + "]");
assert(t>=0.0f && t<=1.0f);
}

View File

@ -222,13 +222,13 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
if(meshHeader.normalFrameCount != meshHeader.vertexFrameCount) {
char szBuf[4096]="";
sprintf(szBuf,"Old v2 model: vertex frame count different from normal frame count [v = %d, n = %d] meshIndex = %d",meshHeader.vertexFrameCount,meshHeader.normalFrameCount,meshIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if(meshHeader.texCoordFrameCount != 1) {
char szBuf[4096]="";
sprintf(szBuf,"Old v2 model: texture coord frame count is not 1 [t = %d] meshIndex = %d",meshHeader.texCoordFrameCount,meshIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//init
@ -313,7 +313,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
if(meshHeader.normalFrameCount != meshHeader.vertexFrameCount) {
char szBuf[4096]="";
sprintf(szBuf,"Old v3 model: vertex frame count different from normal frame count [v = %d, n = %d] meshIndex = %d",meshHeader.vertexFrameCount,meshHeader.normalFrameCount,meshIndex);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//init
@ -614,7 +614,7 @@ void Mesh::save(int meshIndex, const string &dir, FILE *f, TextureManager *textu
}
}
else {
throw runtime_error("Unsupported texture format: [" + convertTextureToFormat + "]");
throw megaglest_runtime_error("Unsupported texture format: [" + convertTextureToFormat + "]");
}
//textureManager->endTexture(texture);
@ -631,10 +631,10 @@ void Mesh::save(int meshIndex, const string &dir, FILE *f, TextureManager *textu
file = extractFileFromDirectoryPath(texture->getPath());
if(file.length() > mapPathSize) {
throw runtime_error("file.length() > mapPathSize, file.length() = " + intToStr(file.length()));
throw megaglest_runtime_error("file.length() > mapPathSize, file.length() = " + intToStr(file.length()));
}
else if(file.length() == 0) {
throw runtime_error("file.length() == 0");
throw megaglest_runtime_error("file.length() == 0");
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Save, new texture file [%s]\n",file.c_str());
@ -787,7 +787,7 @@ void Model::load(const string &path, bool deletePixMapAfterLoad,
loadG3d(path,deletePixMapAfterLoad,loadedFileList, this->sourceLoader);
}
else {
throw runtime_error("Unknown model format: " + extension);
throw megaglest_runtime_error("Unknown model format: " + extension);
}
}
@ -798,7 +798,7 @@ void Model::save(const string &path, string convertTextureToFormat,
saveG3d(path,convertTextureToFormat,keepsmallest);
}
else {
throw runtime_error("Unknown model format: " + extension);
throw megaglest_runtime_error("Unknown model format: " + extension);
}
}
@ -815,7 +815,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
#endif
if (f == NULL) {
printf("In [%s::%s] cannot load file = [%s]\n",__FILE__,__FUNCTION__,path.c_str());
throw runtime_error("Error opening g3d model file [" + path + "]");
throw megaglest_runtime_error("Error opening g3d model file [" + path + "]");
}
if(loadedFileList) {
@ -831,7 +831,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
fclose(f);
f = NULL;
printf("In [%s::%s] file = [%s] fileheader.id = [%s][%c]\n",__FILE__,__FUNCTION__,path.c_str(),reinterpret_cast<char*>(fileHeader.id),fileHeader.id[0]);
throw runtime_error("Not a valid G3D model");
throw megaglest_runtime_error("Not a valid G3D model");
}
fileVersion= fileHeader.version;
@ -847,7 +847,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("meshCount = %d\n",meshCount);
if(modelHeader.type != mtMorphMesh) {
throw runtime_error("Invalid model type");
throw megaglest_runtime_error("Invalid model type");
}
//load meshes
@ -885,14 +885,14 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
}
}
else {
throw runtime_error("Invalid model version: "+ intToStr(fileHeader.version));
throw megaglest_runtime_error("Invalid model version: "+ intToStr(fileHeader.version));
}
fclose(f);
}
catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Exception caught loading 3d file: " + path +"\n"+ e.what());
throw megaglest_runtime_error("Exception caught loading 3d file: " + path +"\n"+ e.what());
}
}
@ -907,7 +907,7 @@ void Model::saveG3d(const string &path, string convertTextureToFormat,
FILE *f= fopen(tempModelFilename.c_str(), "wb");
#endif
if(f == NULL) {
throw runtime_error("Cant open file for writing: [" + tempModelFilename + "]");
throw megaglest_runtime_error("Cant open file for writing: [" + tempModelFilename + "]");
}
convertTextureToFormat = toLower(convertTextureToFormat);
@ -947,7 +947,7 @@ void Model::saveG3d(const string &path, string convertTextureToFormat,
}
}
else {
throw runtime_error("Invalid model version: "+ intToStr(fileHeader.version));
throw megaglest_runtime_error("Invalid model version: "+ intToStr(fileHeader.version));
}
fclose(f);

View File

@ -23,6 +23,7 @@
#include "conversion.h"
#include "model.h"
#include "texture.h"
#include "platform_util.h"
#include "leak_dumper.h"
using namespace std;
@ -143,7 +144,7 @@ ParticleSystem::~ParticleSystem(){
//updates all living particles and creates new ones
void ParticleSystem::update(){
if(aliveParticleCount > (int) particles.size()){
throw runtime_error("aliveParticleCount >= particles.size()");
throw megaglest_runtime_error("aliveParticleCount >= particles.size()");
}
if(particleSystemStartDelay>0){
particleSystemStartDelay--;
@ -190,7 +191,7 @@ ParticleSystem::BlendMode ParticleSystem::strToBlendMode(const string &str){
return bmOneMinusAlpha;
}
else{
throw runtime_error("Unknown particle mode: " + str);
throw megaglest_runtime_error("Unknown particle mode: " + str);
}
}
@ -482,7 +483,7 @@ void ParticleSystem::fade(){
if(state != sPlay) {
char szBuf[4096]="";
sprintf(szBuf,"state != sPlay, state = [%d]",state);
//throw runtime_error(szBuf);
//throw megaglest_runtime_error(szBuf);
//printf(szBuf);
SystemFlags::OutputDebug(SystemFlags::debugError,"%s",szBuf);
}
@ -716,7 +717,7 @@ GameParticleSystem::Primitive GameParticleSystem::strToPrimitive(const string &s
return pLine;
}
else{
throw runtime_error("Unknown particle primitive: " + str);
throw megaglest_runtime_error("Unknown particle primitive: " + str);
}
}
@ -980,7 +981,7 @@ UnitParticleSystem::Shape UnitParticleSystem::strToShape(const string& str){
return sLinear;
}
else{
throw runtime_error("Unknown particle shape: " + str);
throw megaglest_runtime_error("Unknown particle shape: " + str);
}
}
@ -1055,7 +1056,7 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){
#endif
}
} break;
default: throw runtime_error("bad shape");
default: throw megaglest_runtime_error("bad shape");
}
}
@ -1623,7 +1624,7 @@ ProjectileParticleSystem::Trajectory ProjectileParticleSystem::strToTrajectory(c
return tSpiral;
}
else{
throw runtime_error("Unknown particle system trajectory: " + str);
throw megaglest_runtime_error("Unknown particle system trajectory: " + str);
}
}

View File

@ -114,7 +114,7 @@ void PixmapIoTga::openRead(const string &path) {
file= fopen(path.c_str(),"rb");
#endif
if (file == NULL) {
throw runtime_error("Can't open TGA file: "+ path);
throw megaglest_runtime_error("Can't open TGA file: "+ path);
}
//read header
@ -123,16 +123,16 @@ void PixmapIoTga::openRead(const string &path) {
//check that we can load this tga file
if(fileHeader.idLength != 0) {
throw runtime_error(path + ": id field is not 0");
throw megaglest_runtime_error(path + ": id field is not 0");
}
if(fileHeader.dataTypeCode != tgaUncompressedRgb && fileHeader.dataTypeCode != tgaUncompressedBw) {
throw 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");
}
//check bits per pixel
if(fileHeader.bitsPerPixel != 8 && fileHeader.bitsPerPixel != 24 && fileHeader.bitsPerPixel !=32) {
throw 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");
}
h= fileHeader.height;
@ -198,7 +198,7 @@ void PixmapIoTga::openWrite(const string &path, int w, int h, int components) {
file= fopen(path.c_str(),"wb");
#endif
if (file == NULL) {
throw runtime_error("Can't open TGA file: "+ path);
throw megaglest_runtime_error("Can't open TGA file: "+ path);
}
TargaFileHeader fileHeader;
@ -250,21 +250,21 @@ void PixmapIoBmp::openRead(const string &path){
file= fopen(path.c_str(),"rb");
#endif
if (file==NULL){
throw runtime_error("Can't open BMP file: "+ path);
throw megaglest_runtime_error("Can't open BMP file: "+ path);
}
//read file header
BitmapFileHeader fileHeader;
size_t readBytes = fread(&fileHeader, sizeof(BitmapFileHeader), 1, file);
if(fileHeader.type1!='B' || fileHeader.type2!='M'){
throw runtime_error(path +" is not a bitmap");
throw megaglest_runtime_error(path +" is not a bitmap");
}
//read info header
BitmapInfoHeader infoHeader;
readBytes = fread(&infoHeader, sizeof(BitmapInfoHeader), 1, file);
if(infoHeader.bitCount!=24){
throw runtime_error(path+" is not a 24 bit bitmap");
throw megaglest_runtime_error(path+" is not a 24 bit bitmap");
}
h= infoHeader.height;
@ -313,7 +313,7 @@ void PixmapIoBmp::openWrite(const string &path, int w, int h, int components) {
file= fopen(path.c_str(),"wb");
#endif
if (file == NULL) {
throw runtime_error("Can't open BMP file for writing: "+ path);
throw megaglest_runtime_error("Can't open BMP file for writing: "+ path);
}
BitmapFileHeader fileHeader;
@ -366,26 +366,26 @@ PixmapIoPng::~PixmapIoPng() {
void PixmapIoPng::openRead(const string &path) {
throw runtime_error("PixmapIoPng::openRead not implemented!");
throw megaglest_runtime_error("PixmapIoPng::openRead not implemented!");
/*
file= fopen(path.c_str(),"rb");
if (file==NULL){
throw runtime_error("Can't open BMP file: "+ path);
throw megaglest_runtime_error("Can't open BMP file: "+ path);
}
//read file header
BitmapFileHeader fileHeader;
size_t readBytes = fread(&fileHeader, sizeof(BitmapFileHeader), 1, file);
if(fileHeader.type1!='B' || fileHeader.type2!='M'){
throw runtime_error(path +" is not a bitmap");
throw megaglest_runtime_error(path +" is not a bitmap");
}
//read info header
BitmapInfoHeader infoHeader;
readBytes = fread(&infoHeader, sizeof(BitmapInfoHeader), 1, file);
if(infoHeader.bitCount!=24){
throw runtime_error(path+" is not a 24 bit bitmap");
throw megaglest_runtime_error(path+" is not a 24 bit bitmap");
}
h= infoHeader.height;
@ -395,13 +395,13 @@ void PixmapIoPng::openRead(const string &path) {
}
void PixmapIoPng::read(uint8 *pixels) {
throw runtime_error("PixmapIoPng::read not implemented!");
throw megaglest_runtime_error("PixmapIoPng::read not implemented!");
//read(pixels, 3);
}
void PixmapIoPng::read(uint8 *pixels, int components) {
throw runtime_error("PixmapIoPng::read #2 not implemented!");
throw megaglest_runtime_error("PixmapIoPng::read #2 not implemented!");
/*
for(int i=0; i<h*w*components; i+=components) {
@ -442,7 +442,7 @@ void PixmapIoPng::openWrite(const string &path, int w, int h, int components) {
file= fopen(path.c_str(),"wb");
#endif
if (file == NULL) {
throw runtime_error("Can't open PNG file for writing: "+ path);
throw megaglest_runtime_error("Can't open PNG file for writing: "+ path);
}
}
@ -478,7 +478,7 @@ void PixmapIoPng::write(uint8 *pixels) {
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if(!png_ptr) {
fclose(file);
throw runtime_error("OpenGlDevice::saveImageAsPNG() - out of memory creating write structure");
throw megaglest_runtime_error("OpenGlDevice::saveImageAsPNG() - out of memory creating write structure");
}
png_infop info_ptr = png_create_info_struct(png_ptr);
@ -486,7 +486,7 @@ void PixmapIoPng::write(uint8 *pixels) {
png_destroy_write_struct(&png_ptr,
(png_infopp)NULL);
fclose(file);
throw runtime_error("OpenGlDevice::saveImageAsPNG() - out of memery creating info structure");
throw megaglest_runtime_error("OpenGlDevice::saveImageAsPNG() - out of memery creating info structure");
}
// setjmp() must be called in every function that calls a PNG-writing
@ -497,7 +497,7 @@ void PixmapIoPng::write(uint8 *pixels) {
if(setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(file);
throw runtime_error("OpenGlDevice::saveImageAsPNG() - setjmp problem");
throw megaglest_runtime_error("OpenGlDevice::saveImageAsPNG() - setjmp problem");
}
// make sure outfile is (re)opened in BINARY mode
@ -559,7 +559,7 @@ void PixmapIoPng::write(uint8 *pixels) {
if (row_pointers == 0) {
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(file);
throw runtime_error("OpenGlDevice::failed to allocate memory for row pointers");
throw megaglest_runtime_error("OpenGlDevice::failed to allocate memory for row pointers");
}
unsigned int row_stride = this->w * numChannels;
@ -611,16 +611,16 @@ PixmapIoJpg::~PixmapIoJpg() {
void PixmapIoJpg::openRead(const string &path) {
throw runtime_error("PixmapIoJpg::openRead not implemented!");
throw megaglest_runtime_error("PixmapIoJpg::openRead not implemented!");
}
void PixmapIoJpg::read(uint8 *pixels) {
throw runtime_error("PixmapIoJpg::read not implemented!");
throw megaglest_runtime_error("PixmapIoJpg::read not implemented!");
}
void PixmapIoJpg::read(uint8 *pixels, int components) {
throw runtime_error("PixmapIoJpg::read #2 not implemented!");
throw megaglest_runtime_error("PixmapIoJpg::read #2 not implemented!");
}
void PixmapIoJpg::openWrite(const string &path, int w, int h, int components) {
@ -635,7 +635,7 @@ void PixmapIoJpg::openWrite(const string &path, int w, int h, int components) {
file= fopen(path.c_str(),"wb");
#endif
if (file == NULL) {
throw runtime_error("Can't open JPG file for writing: "+ path);
throw megaglest_runtime_error("Can't open JPG file for writing: "+ path);
}
}
@ -777,7 +777,7 @@ void Pixmap1D::load(const string &path) {
loadTga(path);
}
else {
throw runtime_error("Unknown pixmap extension: " + extension);
throw megaglest_runtime_error("Unknown pixmap extension: " + extension);
}
this->path = path;
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
@ -797,7 +797,7 @@ void Pixmap1D::loadBmp(const string &path) {
w= plb.getH();
}
else {
throw runtime_error("One of the texture dimensions must be 1");
throw megaglest_runtime_error("One of the texture dimensions must be 1");
}
if(components == -1) {
@ -825,7 +825,7 @@ void Pixmap1D::loadTga(const string &path) {
w= plt.getH();
}
else {
throw runtime_error("One of the texture dimensions must be 1");
throw megaglest_runtime_error("One of the texture dimensions must be 1");
}
int fileComponents= plt.getComponents();
@ -893,7 +893,7 @@ void Pixmap2D::init(int w, int h, int components) {
if(getPixelByteCount() <= 0 || (h <= 0 || w <= 0 || components <= 0)) {
char szBuf[1024];
sprintf(szBuf,"Invalid pixmap dimensions for [%s], h = %d, w = %d, components = %d\n",path.c_str(),h,w,components);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
pixels= new uint8[(std::size_t)getPixelByteCount()];
CalculatePixelsCRC(pixels,0, crc);
@ -977,7 +977,7 @@ void Pixmap2D::save(const string &path) {
savePng(path);
}
else {
throw runtime_error("Unknown pixmap extension: " + extension);
throw megaglest_runtime_error("Unknown pixmap extension: " + extension);
}
}
@ -1158,7 +1158,7 @@ void Pixmap2D::splat(const Pixmap2D *leftUp, const Pixmap2D *rightUp, const Pixm
!doDimensionsAgree(leftDown) ||
!doDimensionsAgree(rightDown))
{
throw runtime_error("Pixmap2D::splat: pixmap dimensions don't agree");
throw megaglest_runtime_error("Pixmap2D::splat: pixmap dimensions don't agree");
}
for(int i=0; i<w; ++i){
@ -1207,7 +1207,7 @@ void Pixmap2D::lerp(float t, const Pixmap2D *pixmap1, const Pixmap2D *pixmap2){
!doDimensionsAgree(pixmap1) ||
!doDimensionsAgree(pixmap2))
{
throw runtime_error("Pixmap2D::lerp: pixmap dimensions don't agree");
throw megaglest_runtime_error("Pixmap2D::lerp: pixmap dimensions don't agree");
}
for(int i=0; i<w; ++i){
@ -1222,7 +1222,7 @@ void Pixmap2D::copy(const Pixmap2D *sourcePixmap){
assert(components==sourcePixmap->getComponents());
if(w!=sourcePixmap->getW() || h!=sourcePixmap->getH()){
throw runtime_error("Pixmap2D::copy() dimensions must agree");
throw megaglest_runtime_error("Pixmap2D::copy() dimensions must agree");
}
memcpy(pixels, sourcePixmap->getPixels(), w*h*sourcePixmap->getComponents());
this->path = sourcePixmap->path;
@ -1233,7 +1233,7 @@ void Pixmap2D::subCopy(int x, int y, const Pixmap2D *sourcePixmap){
assert(components==sourcePixmap->getComponents());
if(w<sourcePixmap->getW() && h<sourcePixmap->getH()){
throw runtime_error("Pixmap2D::subCopy(), bad dimensions");
throw megaglest_runtime_error("Pixmap2D::subCopy(), bad dimensions");
}
uint8 *pixel= new uint8[components];
@ -1335,7 +1335,7 @@ void Pixmap3D::loadSlice(const string &path, int slice) {
loadSliceTga(path, slice);
}
else {
throw runtime_error("Unknown pixmap extension: "+extension);
throw megaglest_runtime_error("Unknown pixmap extension: "+extension);
}
this->path = path;
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);

View File

@ -13,7 +13,7 @@
#include <stdexcept>
#include <fstream>
#include "platform_util.h"
#include "leak_dumper.h"
using namespace std;
@ -30,7 +30,7 @@ void ShaderSource::load(const string &path){
//open file
ifstream ifs(path.c_str());
if(ifs.fail()){
throw runtime_error("Can't open shader file: " + path);
throw megaglest_runtime_error("Can't open shader file: " + path);
}
//read source

View File

@ -10,12 +10,11 @@
// ==============================================================
#include "shader_manager.h"
#include <stdexcept>
#include "graphics_interface.h"
#include "graphics_factory.h"
#include "util.h"
#include "platform_util.h"
#include "leak_dumper.h"
using namespace Shared::Util;
@ -37,13 +36,13 @@ void ShaderManager::init(){
for(unsigned int i=0; i<shaders.size(); ++i){
shaders[i]->init();
if(!shaders[i]->compile(logString)){
throw runtime_error("Can't compile shader\n");
throw megaglest_runtime_error("Can't compile shader\n");
}
}
for(unsigned int i=0; i<shaderPrograms.size(); ++i){
shaderPrograms[i]->init();
if(!shaderPrograms[i]->link(logString)){
throw runtime_error("Can't link shader\n");
throw megaglest_runtime_error("Can't link shader\n");
}
}
}

View File

@ -78,23 +78,28 @@ void Texture1D::deletePixels() {
// class Texture2D
// =====================================================
SDL_Surface* Texture2D::CreateSDLSurface(bool newPixelData) const {
SDL_Surface* surface = NULL;
std::pair<SDL_Surface*,unsigned char*> Texture2D::CreateSDLSurface(bool newPixelData) const {
std::pair<SDL_Surface*,unsigned char*> result;
result.first = NULL;
result.second = NULL;
unsigned char* surfData = NULL;
if (newPixelData == true) {
// copy pixel data
surfData = new unsigned char[pixmap.getW() * pixmap.getH() * pixmap.getComponents()];
memcpy(surfData, pixmap.getPixels(), pixmap.getW() * pixmap.getH() * pixmap.getComponents());
} else {
}
else {
surfData = pixmap.getPixels();
}
result.second = surfData;
// This will only work with 24bit RGB and 32bit RGBA pictures
surface = SDL_CreateRGBSurfaceFrom(surfData, pixmap.getW(), pixmap.getH(), 8 * pixmap.getComponents(), pixmap.getW() * pixmap.getComponents(), 0x000000FF, 0x0000FF00, 0x00FF0000, (pixmap.getComponents() == 4) ? 0xFF000000 : 0);
if ((surface == NULL) && newPixelData == true) {
result.first = SDL_CreateRGBSurfaceFrom(surfData, pixmap.getW(), pixmap.getH(), 8 * pixmap.getComponents(), pixmap.getW() * pixmap.getComponents(), 0x000000FF, 0x0000FF00, 0x00FF0000, (pixmap.getComponents() == 4) ? 0xFF000000 : 0);
if ((result.first == NULL) && newPixelData == true) {
// cleanup when we failed to the create surface
delete[] surfData;
result.second = NULL;
}
// SDL_Surface *prepGLTexture(SDL_Surface *surface, GLfloat *texCoords = NULL, const bool
@ -102,8 +107,8 @@ SDL_Surface* Texture2D::CreateSDLSurface(bool newPixelData) const {
/* Use the surface width and height expanded to powers of 2 */
//int w = powerOfTwo(surface->w);
//int h = powerOfTwo(surface->h);
int w = surface->w;
int h = surface->h;
int w = result.first->w;
int h = result.first->h;
// if (texCoords != 0) {
// texCoords[0] = 0.0f; /* Min
@ -131,14 +136,15 @@ SDL_Surface* Texture2D::CreateSDLSurface(bool newPixelData) const {
#endif
);
if ( image == NULL ) {
return 0;
result.first = NULL;
return result;
}
/* Save the alpha blending attributes */
Uint32 savedFlags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
Uint8 savedAlpha = surface->format->alpha;
Uint32 savedFlags = result.first->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
Uint8 savedAlpha = result.first->format->alpha;
if ( (savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
SDL_SetAlpha(surface, 0, 0);
SDL_SetAlpha(result.first, 0, 0);
}
SDL_Rect srcArea, destArea;
@ -147,14 +153,14 @@ SDL_Surface* Texture2D::CreateSDLSurface(bool newPixelData) const {
/* Copy it in at the bottom, because we're going to flip
this image upside-down in a moment
*/
srcArea.y = 0; destArea.y = h - surface->h;
srcArea.w = surface->w;
srcArea.h = surface->h;
SDL_BlitSurface(surface, &srcArea, image, &destArea);
srcArea.y = 0; destArea.y = h - result.first->h;
srcArea.w = result.first->w;
srcArea.h = result.first->h;
SDL_BlitSurface(result.first, &srcArea, image, &destArea);
/* Restore the alpha blending attributes */
if ((savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA) {
SDL_SetAlpha(surface, savedFlags, savedAlpha);
SDL_SetAlpha(result.first, savedFlags, savedAlpha);
}
/* Turn the image upside-down, because OpenGL textures
@ -190,10 +196,10 @@ SDL_Surface* Texture2D::CreateSDLSurface(bool newPixelData) const {
delete[] line;
#endif
return image;
result.first = image;
// }
return surface;
return result;
}
void Texture2D::load(const string &path){

View File

@ -12,9 +12,9 @@
#include "lua_script.h"
#include <stdexcept>
#include "conversion.h"
#include "util.h"
#include "platform_util.h"
#include "leak_dumper.h"
using namespace std;
@ -55,7 +55,7 @@ LuaScript::LuaScript() {
luaL_openlibs(luaState);
if(luaState==NULL){
throw runtime_error("Can not allocate lua state");
throw megaglest_runtime_error("Can not allocate lua state");
}
argumentCount= -1;
@ -421,7 +421,7 @@ void LuaScript::loadCode(const string &code, const string &name){
printf("Function name [%s]\ncode:\n%s\n",name.c_str(),code.c_str());
printf("=========================================================\n");
throw runtime_error("Error loading lua code: " + errorToString(errorCode));
throw megaglest_runtime_error("Error loading lua code: " + errorToString(errorCode));
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode);
@ -433,7 +433,7 @@ void LuaScript::loadCode(const string &code, const string &name){
printf("Error calling lua pcall: %s\n",errorToString(errorCode).c_str());
printf("=========================================================\n");
throw runtime_error("Error initializing lua: " + errorToString(errorCode));
throw megaglest_runtime_error("Error initializing lua: " + errorToString(errorCode));
}
//const char *errMsg = lua_tostring(luaState, -1);
@ -464,7 +464,7 @@ void LuaScript::endCall() {
if(currentLuaFunctionIsValid == true) {
int errorCode= lua_pcall(luaState, argumentCount, 0, 0);
if(errorCode !=0 ) {
throw runtime_error("Error calling lua function [" + currentLuaFunction + "] error: " + errorToString(errorCode));
throw megaglest_runtime_error("Error calling lua function [" + currentLuaFunction + "] error: " + errorToString(errorCode));
}
}
else
@ -652,7 +652,7 @@ void LuaArguments::throwLuaError(const string &message) const{
stackString+= "\n";
}
throw runtime_error("Lua error: " + message + "\n\nLua Stack:\n" + stackString);
throw megaglest_runtime_error("Lua error: " + message + "\n\nLua Stack:\n" + stackString);
}
}}//end namespace

View File

@ -502,26 +502,26 @@ void MapPreview::reset(int w, int h, float alt, MapSurfaceType surf) {
if (w < MIN_MAP_CELL_DIMENSION || h < MIN_MAP_CELL_DIMENSION) {
char szBuf[1024]="";
sprintf(szBuf,"Size of map must be at least %dx%d",MIN_MAP_CELL_DIMENSION,MIN_MAP_CELL_DIMENSION);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
return;
}
if (w > MAX_MAP_CELL_DIMENSION || h > MAX_MAP_CELL_DIMENSION) {
char szBuf[1024]="";
sprintf(szBuf,"Size of map can be at most %dx%d",MAX_MAP_CELL_DIMENSION,MAX_MAP_CELL_DIMENSION);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if (alt < MIN_MAP_CELL_HEIGHT || alt > MAX_MAP_CELL_HEIGHT) {
char szBuf[1024]="";
sprintf(szBuf,"Height must be in the range %d-%d",MIN_MAP_CELL_HEIGHT,MAX_MAP_CELL_HEIGHT);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if (surf < st_Grass || surf > st_Ground) {
char szBuf[1024]="";
sprintf(szBuf,"Surface must be in the range %d-%d",st_Grass,st_Ground);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//if (cells != NULL) {
@ -554,26 +554,26 @@ void MapPreview::resize(int w, int h, float alt, MapSurfaceType surf) {
if (w < MIN_MAP_CELL_DIMENSION || h < MIN_MAP_CELL_DIMENSION) {
char szBuf[1024]="";
sprintf(szBuf,"Size of map must be at least %dx%d",MIN_MAP_CELL_DIMENSION,MIN_MAP_CELL_DIMENSION);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
return;
}
if (w > MAX_MAP_CELL_DIMENSION || h > MAX_MAP_CELL_DIMENSION) {
char szBuf[1024]="";
sprintf(szBuf,"Size of map can be at most %dx%d",MAX_MAP_CELL_DIMENSION,MAX_MAP_CELL_DIMENSION);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if (alt < MIN_MAP_CELL_HEIGHT || alt > MAX_MAP_CELL_HEIGHT) {
char szBuf[1024]="";
sprintf(szBuf,"Height must be in the range %d-%d",MIN_MAP_CELL_HEIGHT,MAX_MAP_CELL_HEIGHT);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
if (surf < st_Grass || surf > st_Ground) {
char szBuf[1024]="";
sprintf(szBuf,"Surface must be in the range %d-%d",st_Grass,st_Ground);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
int oldW = this->w;
@ -629,7 +629,7 @@ void MapPreview::resetFactions(int maxPlayers) {
if (maxPlayers < MIN_MAP_FACTIONCOUNT || maxPlayers > MAX_MAP_FACTIONCOUNT) {
char szBuf[1024]="";
sprintf(szBuf,"Max Players must be in the range %d-%d",MIN_MAP_FACTIONCOUNT,MAX_MAP_FACTIONCOUNT);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
//if (startLocations != NULL) {
@ -704,7 +704,7 @@ void MapPreview::switchSurfaces(MapSurfaceType surf1, MapSurfaceType surf2) {
}
}
else {
throw runtime_error("Incorrect surfaces");
throw megaglest_runtime_error("Incorrect surfaces");
}
}
@ -786,7 +786,7 @@ void MapPreview::loadFromFile(const string &path) {
string strError = "[#5] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
throw strError;
#else
throw runtime_error("[#5] error opening map file: " + path);
throw megaglest_runtime_error("[#5] error opening map file: " + path);
#endif
}
}
@ -856,7 +856,7 @@ void MapPreview::saveToFile(const string &path) {
}
else {
throw runtime_error("Error opening map file: " + path);
throw megaglest_runtime_error("Error opening map file: " + path);
}
void randomHeight(int x, int y, int height);
@ -935,7 +935,7 @@ bool MapPreview::loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPla
f= fopen(file.c_str(), "rb");
#endif
if(f == NULL) {
throw runtime_error("Can't open file");
throw megaglest_runtime_error("Can't open file");
}
MapFileHeader header;
@ -948,7 +948,7 @@ bool MapPreview::loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPla
sprintf(szBuf,"In [%s::%s Line: %d]\nfile [%s]\nreadBytes != sizeof(MapFileHeader) [%lu] [%lu]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str(),readBytes,sizeof(MapFileHeader));
SystemFlags::OutputDebug(SystemFlags::debugError,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
else {
@ -960,7 +960,7 @@ bool MapPreview::loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPla
printf("In [%s::%s Line: %d]\file [%s]\nheader.version < mapver_1 || header.version >= mapver_MAX [%d] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str(),header.version,mapver_MAX);
SystemFlags::OutputDebug(SystemFlags::debugError,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
else if(header.maxFactions <= 0 || header.maxFactions > MAX_MAP_FACTIONCOUNT) {
@ -971,7 +971,7 @@ bool MapPreview::loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPla
printf("In [%s::%s Line: %d]\file [%s]\nheader.maxFactions <= 0 || header.maxFactions > MAX_MAP_FACTIONCOUNT [%d] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str(),header.maxFactions,MAX_MAP_FACTIONCOUNT);
SystemFlags::OutputDebug(SystemFlags::debugError,"%s",szBuf);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
}
else {
@ -993,7 +993,7 @@ bool MapPreview::loadMapInfo(string file, MapInfo *mapInfo, string i18nMaxMapPla
//assert(0);
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] loading map [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what(),file.c_str());
throw runtime_error("Error loading map file: [" + file + "] msg: " + e.what() + " errno [" + intToStr(errno) + "] [" + strerror(errno) + "]");
throw megaglest_runtime_error("Error loading map file: [" + file + "] msg: " + e.what() + " errno [" + intToStr(errno) + "] [" + strerror(errno) + "]");
}
return validMap;
@ -1023,7 +1023,7 @@ string MapPreview::getMapPath(const vector<string> &pathList, const string &mapN
}
if(errorOnNotFound == true) {
throw runtime_error("Map [" + mapName + "] not found, scenarioDir [" + scenarioDir + "]");
throw megaglest_runtime_error("Map [" + mapName + "] not found, scenarioDir [" + scenarioDir + "]");
}
return "";

View File

@ -14,6 +14,7 @@
#include "platform_common.h"
#include "util.h"
#include "conversion.h"
#include "platform_util.h"
#include <time.h>
using namespace Shared::Util;
@ -52,7 +53,7 @@ BaseThread::~BaseThread() {
if(masterThreadList.find(this) == masterThreadList.end()) {
char szBuf[4096]="";
sprintf(szBuf,"invalid thread delete for ptr: %p",this);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
masterThreadList[this]--;
if(masterThreadList[this] <= 0) {

View File

@ -343,7 +343,7 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
if(errorOnNotFound) {
std::stringstream msg;
msg << "#1 Couldn't scan directory '" << mypath << "': " << strerror(errno);
throw runtime_error(msg.str());
throw megaglest_runtime_error(msg.str());
}
}
else {
@ -366,7 +366,7 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
globfree(&globbuf);
if(results.empty() == true && errorOnNotFound == true) {
throw runtime_error("No files found in: " + mypath);
throw megaglest_runtime_error("No files found in: " + mypath);
}
if(cutExtension) {
@ -890,7 +890,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
if(res < 0) {
std::stringstream msg;
msg << "#2 Couldn't scan directory '" << mypath << "': " << strerror(errno);
throw runtime_error(msg.str());
throw megaglest_runtime_error(msg.str());
}
#endif
@ -930,7 +930,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
if(res < 0) {
std::stringstream msg;
msg << "#3 Couldn't scan directory '" << mypath << "': " << strerror(errno);
throw runtime_error(msg.str());
throw megaglest_runtime_error(msg.str());
}
#endif
@ -1071,7 +1071,7 @@ vector<string> getFolderTreeContentsListRecursively(const string &path, const st
if(res < 0) {
std::stringstream msg;
msg << "#4 Couldn't scan directory '" << mypath << "': " << strerror(errno);
throw runtime_error(msg.str());
throw megaglest_runtime_error(msg.str());
}
#endif
for(int i = 0; i < globbuf.gl_pathc; ++i) {
@ -1111,7 +1111,7 @@ vector<string> getFolderTreeContentsListRecursively(const string &path, const st
if(res < 0) {
std::stringstream msg;
msg << "#5 Couldn't scan directory '" << mypath << "': " << strerror(errno);
throw runtime_error(msg.str());
throw megaglest_runtime_error(msg.str());
}
#endif
@ -1212,7 +1212,7 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(co
if(res < 0) {
std::stringstream msg;
msg << "#6 Couldn't scan directory '" << mypath << "': " << strerror(errno);
throw runtime_error(msg.str());
throw megaglest_runtime_error(msg.str());
}
#endif
@ -1250,7 +1250,7 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(co
if(res < 0) {
std::stringstream msg;
msg << "#7 Couldn't scan directory '" << mypath << "': " << strerror(errno);
throw runtime_error(msg.str());
throw megaglest_runtime_error(msg.str());
}
#endif
@ -1981,12 +1981,12 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
if(fp1 == NULL) {
if(fp2) fclose(fp2);
throw runtime_error("cannot open input file [" + fileName + "]");
throw megaglest_runtime_error("cannot open input file [" + fileName + "]");
}
if(fp2 == NULL) {
if(fp1) fclose(fp1);
throw runtime_error("cannot open output file [" + tempfileName + "]");
throw megaglest_runtime_error("cannot open output file [" + tempfileName + "]");
}
while(fgets(buffer,MAX_LEN_SINGLE_LINE + 2,fp1)) {
@ -2039,10 +2039,10 @@ void copyFileTo(string fromFileName, string toFileName) {
}
}
else if(in.is_open() == false) {
throw runtime_error("cannot open input file [" + fromFileName + "]");
throw megaglest_runtime_error("cannot open input file [" + fromFileName + "]");
}
else if(out.is_open() == false) {
throw runtime_error("cannot open input file [" + toFileName + "]");
throw megaglest_runtime_error("cannot open input file [" + toFileName + "]");
}
//Close both files

View File

@ -15,6 +15,7 @@
#include "platform_common.h"
#include <algorithm>
#include "conversion.h"
#include "platform_util.h"
#include "leak_dumper.h"
using namespace std;
@ -316,7 +317,7 @@ SimpleTaskThread::~SimpleTaskThread() {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
//throw runtime_error(ex.what());
//throw megaglest_runtime_error(ex.what());
abort();
}
}
@ -417,7 +418,7 @@ void SimpleTaskThread::execute() {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
throw runtime_error(ex.what());
throw megaglest_runtime_error(ex.what());
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
@ -590,7 +591,7 @@ void LogFileThread::saveToDisk(bool forceSaveAll,bool logListAlreadyLocked) {
if(logList.size() <= logCount) {
char szBuf[1024]="";
sprintf(szBuf,"logList.size() <= logCount [%lld][%lld]",(long long int)logList.size(),(long long int)logCount);
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
logList.erase(logList.begin(),logList.begin() + logCount);
}

View File

@ -1438,7 +1438,7 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) {
bytesReceived += additionalBytes;
}
else {
//throw runtime_error("additionalBytes == " + intToStr(additionalBytes));
//throw megaglest_runtime_error("additionalBytes == " + intToStr(additionalBytes));
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] additionalBytes == %d\n",__FILE__,__FUNCTION__,__LINE__,additionalBytes);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nIn [%s::%s Line: %d] additionalBytes == %d\n",__FILE__,__FUNCTION__,__LINE__,additionalBytes);
if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] additionalBytes == %d\n",__FILE__,__FUNCTION__,__LINE__,additionalBytes);
@ -1727,13 +1727,13 @@ string Socket::getIp() {
unsigned char* address;
if(info==NULL){
throw runtime_error("Error getting host by name");
throw megaglest_runtime_error("Error getting host by name");
}
address= reinterpret_cast<unsigned char*>(info->h_addr_list[0]);
if(address==NULL){
throw runtime_error("Error getting host ip");
throw megaglest_runtime_error("Error getting host ip");
}
return
@ -1745,7 +1745,7 @@ string Socket::getIp() {
void Socket::throwException(string str){
string msg = str + " " + getLastSocketErrorFormattedText();
throw runtime_error(msg);
throw megaglest_runtime_error(msg);
}
// ===============================================
@ -2202,7 +2202,7 @@ void ServerSocket::bind(int port) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"%s",szBuf);
sprintf(szBuf, "Error binding socket sock = %d, err = %d, error = %s\n",sock,err,getLastSocketErrorFormattedText().c_str());
throw runtime_error(szBuf);
throw megaglest_runtime_error(szBuf);
}
portBound = true;
@ -2636,7 +2636,7 @@ void UPNP_Tools::NETaddRedirects(std::vector<int> UPNPPortForwardList,bool mutex
if(UPNPPortForwardList.size() % 2 != 0) {
// We need groups of 2 ports.. one external and one internal for opening ports on UPNP router
throw runtime_error("UPNPPortForwardList.size() MUST BE divisable by 2");
throw megaglest_runtime_error("UPNPPortForwardList.size() MUST BE divisable by 2");
}
for(unsigned int clientIndex = 0; clientIndex < UPNPPortForwardList.size(); clientIndex += 2) {

View File

@ -27,7 +27,7 @@ GraphicsFactory *FactoryRepository::getGraphicsFactory(const string &name) {
return &graphicsFactoryGl;
}
throw runtime_error("Unknown graphics factory: " + name);
throw megaglest_runtime_error("Unknown graphics factory: " + name);
}
SoundFactory *FactoryRepository::getSoundFactory(const string &name) {
@ -38,7 +38,7 @@ SoundFactory *FactoryRepository::getSoundFactory(const string &name) {
return &soundFactoryNone;
}
throw runtime_error("Unknown sound factory: " + name);
throw megaglest_runtime_error("Unknown sound factory: " + name);
}
}}//end namespace

Some files were not shown because too many files have changed in this diff Show More