- added a backtrace for gcc compiled binary when we get a runtime error.

- added more out of synch checks and better error handling
This commit is contained in:
Mark Vejvoda 2011-01-02 00:39:13 +00:00
parent 67be9b7b40
commit 896b1c308c
21 changed files with 940 additions and 648 deletions

View File

@ -32,7 +32,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
# Default compiler flags
#SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s") ## Strip binary
ADD_DEFINITIONS("-fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse")
ADD_DEFINITIONS("-fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -rdynamic")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# Debug compiler flags

View File

@ -224,7 +224,7 @@ CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *command
}
}
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, const UnitType *ut){
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, const UnitType *ut) {
assert(this->gameSettings != NULL);
const Unit *unit = getMyUnit(unitIndex);

View File

@ -882,13 +882,13 @@ void AiRuleBuild::buildBestBuilding(const vector<const UnitType*> &buildings){
}
}
void AiRuleBuild::buildSpecific(const BuildTask *bt){
void AiRuleBuild::buildSpecific(const BuildTask *bt) {
AiInterface *aiInterface= ai->getAiInterface();
//if reqs ok
if(aiInterface->reqsOk(bt->getUnitType())){
if(aiInterface->reqsOk(bt->getUnitType())) {
//retry if not enough resources
if(!aiInterface->checkCosts(bt->getUnitType())){
if(aiInterface->checkCosts(bt->getUnitType()) == false) {
ai->retryTask(bt);
return;
}
@ -900,28 +900,28 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt){
const BuildCommandType *defBct= NULL;
//for each unit
for(int i=0; i<aiInterface->getMyUnitCount(); ++i){
for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) {
//if the unit is not going to build
const Unit *u= aiInterface->getMyUnit(i);
if(!u->anyCommand() || u->getCurrCommand()->getCommandType()->getClass()!=ccBuild){
const Unit *u = aiInterface->getMyUnit(i);
if(u->anyCommand() == false || u->getCurrCommand()->getCommandType()->getClass() != ccBuild) {
//for each command
const UnitType *ut= aiInterface->getMyUnit(i)->getType();
for(int j=0; j<ut->getCommandTypeCount(); ++j){
for(int j = 0; j < ut->getCommandTypeCount(); ++j) {
const CommandType *ct= ut->getCommandType(j);
//if the command is build
if(ct->getClass()==ccBuild){
if(ct->getClass() == ccBuild) {
const BuildCommandType *bct= static_cast<const BuildCommandType*>(ct);
//for each building
for(int k=0; k<bct->getBuildingCount(); ++k){
for(int k = 0; k < bct->getBuildingCount(); ++k) {
const UnitType *building= bct->getBuilding(k);
//if building match
if(bt->getUnitType()==building){
if(aiInterface->reqsOk(bct)){
if(bt->getUnitType() == building) {
if(aiInterface->reqsOk(bct)) {
builders.push_back(i);
buildersDefaultCommandType[i].push_back(bct);
defBct= bct;
@ -934,15 +934,14 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt){
}
//use random builder to build
if(!builders.empty()){
if(builders.empty() == false) {
int bIndex = ai->getRandom()->randRange(0, builders.size()-1);
int builderIndex= builders[bIndex];
Vec2i pos;
Vec2i searchPos= bt->getForcePos()? bt->getPos(): ai->getRandomHomePosition();
//if free pos give command, else retry
if(ai->findPosForBuilding(bt->getUnitType(), searchPos, pos)){
if(ai->findPosForBuilding(bt->getUnitType(), searchPos, pos)) {
defBct = NULL;
if(buildersDefaultCommandType.find(builderIndex) != buildersDefaultCommandType.end()) {
//defBct = buildersDefaultCommandType[builderIndex];
@ -952,13 +951,12 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] bestCommandTypeIndex = %d, bestCommandTypeCount = %d\n",__FILE__,__FUNCTION__,__LINE__,bestCommandTypeIndex,bestCommandTypeCount);
defBct = buildersDefaultCommandType[builderIndex][bestCommandTypeIndex];
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] builderIndex = %d, bIndex = %d, defBct = %p\n",__FILE__,__FUNCTION__,__LINE__,builderIndex,bIndex,defBct);
aiInterface->giveCommand(builderIndex, defBct, pos, bt->getUnitType());
}
else{
else {
ai->retryTask(bt);
return;
}

View File

@ -495,21 +495,38 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
throw runtime_error(szBuf);
}
ct= unit->getType()->findCommandTypeById(networkCommand->getCommandTypeId());
if(unit->getFaction()->getIndex() != networkCommand->getUnitFactionIndex()) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d]\nUnit / Faction mismatch for network command = [%s]\n%s\nfor unit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.",
__FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex());
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
std::string worldLog = world->DumpWorldToLog();
//std::string sError = "worldLog = " + worldLog + " " + string(szBuf);
std::string sError = "Error [#1]: Game is out of sync, please check log files for details.";
std::string sError = "Error [#1]: Game is out of sync (Unit / Faction mismatch)\nplease check log files for details.";
throw runtime_error(sError);
}
else if(networkCommand->getUnitTypeId() >= 0 &&
unit->getType()->getId() != networkCommand->getUnitTypeId() &&
ct->getClass() != ccBuild) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d]\nUnit / Type mismatch for network command = [%s]\n%s\nfor unit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nactual local unitTypeId = %d.\nGame out of synch.",
__FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex(),unit->getType()->getId());
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
std::string worldLog = world->DumpWorldToLog();
//std::string sError = "worldLog = " + worldLog + " " + string(szBuf);
std::string sError = "Error [#2]: Game is out of sync (unit type mismatch)\nplease check log files for details.";
throw runtime_error(sError);
}
const UnitType* unitType= world->findUnitTypeById(unit->getFaction()->getType(), networkCommand->getUnitTypeId());
ct= unit->getType()->findCommandTypeById(networkCommand->getCommandTypeId());
// debug test!
//throw runtime_error("Test missing command type!");
@ -544,13 +561,13 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
//create command
Command *command= NULL;
if(unitType!=NULL){
if(unitType != NULL) {
command= new Command(ct, networkCommand->getPosition(), unitType, facing);
}
else if(target==NULL){
else if(target == NULL) {
command= new Command(ct, networkCommand->getPosition());
}
else{
else {
command= new Command(ct, target);
}

View File

@ -140,6 +140,8 @@ Game::~Game() {
Unit::setGame(NULL);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== END GAME ==== getCurrentPixelByteCount() = %llu\n",__FILE__,__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== END GAME ====\n");
//this->program->reInitGl();
//renderer.reinitAll();
}
@ -649,6 +651,7 @@ void Game::init(bool initForPreviewOnly)
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"PathFinderType: %s\n", (getGameSettings()->getPathFinderType() ? "RoutePlanner" : "PathFinder"));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== START GAME ==== getCurrentPixelByteCount() = %llu\n",__FILE__,__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== START GAME ====\n");
}
// ==================== update ====================
@ -663,6 +666,16 @@ void Game::update() {
// a) Updates non dependent on speed
if(NetworkManager::getInstance().getGameNetworkInterface() != NULL &&
NetworkManager::getInstance().getGameNetworkInterface()->getQuit() &&
mainMessageBox.getEnabled() == false &&
errorMessageBox.getEnabled() == false) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//quitGame();
quitTriggeredIndicator = true;
return;
}
//misc
updateFps++;
mouse2d= (mouse2d+1) % Renderer::maxMouse2dAnim;
@ -783,8 +796,10 @@ void Game::update() {
if(networkManager.getGameNetworkInterface() != NULL) {
networkManager.getGameNetworkInterface()->quitGame(true);
}
if(errorMessageBox.getEnabled() == false) {
ErrorDisplayMessage(ex.what(),true);
}
}
}
void Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRole role) {
@ -1407,6 +1422,10 @@ void Game::keyPress(char c){
Stats Game::quitGame() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled == true) {
world.DumpWorldToLog();
}
//Stats stats = *(world.getStats());
Stats endStats;

View File

@ -36,6 +36,12 @@
#include "font_gl.h"
#include "cache_manager.h"
// For gcc backtrace on crash!
#ifdef __GNUC__
#include <execinfo.h>
#include <cxxabi.h>
#endif
#ifdef WIN32
#if defined(__WIN32__) && !defined(__GNUC__)
#include <eh.h>
@ -70,6 +76,7 @@ using namespace Shared::Graphics::Gl;
namespace Glest{ namespace Game{
bool gameInitialized = false;
static char *application_binary=NULL;
const char *GAME_ARGS[] = {
"--help",
@ -191,18 +198,222 @@ public:
message(msg.c_str());
}
#ifdef __GNUC__
static int getFileAndLine(void *address, char *file, size_t flen) {
int line=-1;
static char buf[256]="";
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,address);
FILE* f = popen (buf, "r");
if (f == NULL) {
perror (buf);
return 0;
}
// get function name
char *ret = fgets (buf, 256, f);
// get file and line
ret = fgets (buf, 256, f);
if (buf[0] != '?') {
int l;
char *p = buf;
// file name is until ':'
while (*p != ':')
{
p++;
}
*p++ = 0;
// after file name follows line number
strcpy (file , buf);
sscanf (p,"%d", &line);
}
else {
strcpy (file,"unkown");
line = 0;
}
pclose(f);
return line;
}
static void * getStackAddress(const unsigned int index) {
//printf("\nSTART index = %d\n",index);
void *lineAddress = NULL;
if(index == 0) {
lineAddress = __builtin_return_address(0);
}
if(index == 1) {
lineAddress = __builtin_return_address(1);
}
if(index == 2) {
lineAddress = __builtin_return_address(2);
}
if(index == 3) {
lineAddress = __builtin_return_address(3);
}
if(index == 4) {
lineAddress = __builtin_return_address(4);
}
if(index == 5) {
lineAddress = __builtin_return_address(5);
}
if(index == 6) {
lineAddress = __builtin_return_address(6);
}
if(index == 7) {
lineAddress = __builtin_return_address(7);
}
if(index == 8) {
lineAddress = __builtin_return_address(8);
}
if(index == 9) {
lineAddress = __builtin_return_address(9);
}
if(index == 10) {
lineAddress = __builtin_return_address(10);
}
if(index == 11) {
lineAddress = __builtin_return_address(11);
}
if(index == 12) {
lineAddress = __builtin_return_address(12);
}
if(index == 13) {
lineAddress = __builtin_return_address(13);
}
if(index == 14) {
lineAddress = __builtin_return_address(14);
}
if(index == 15) {
lineAddress = __builtin_return_address(15);
}
//printf("\nEND index = %d lineAddress [%p]\n",index,lineAddress);
return lineAddress;
}
#endif
static void handleRuntimeError(const char *msg) {
Program *program = Program::getInstance();
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s] gameInitialized = %d, program = %p\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized,program);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s] gameInitialized = %d, program = %p\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized,program);
if(program && gameInitialized == true) {
//SystemFlags::Close();
program->showMessage(msg);
string errMsg = (msg != NULL ? msg : "null");
#ifdef __GNUC__
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 = 15;
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";
//}
char szBuf[4096]="";
for(size_t i = 1; i < stack_depth; i++) {
const unsigned int stackIndex = i-1;
void *lineAddress = getStackAddress(stackIndex);
size_t sz = 1024; // 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 {
string err = "#2 An error ocurred and " + string(GameConstants::application_name) + " will close.\nError msg = [" + (msg != NULL ? string(msg) : string("?")) + "]\n\nPlease report this bug to "+mailString;
// 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[4096]="";
int line = getFileAndLine(lineAddress, file, 4096);
if(line >= 0) {
errMsg += " line: " + intToStr(line);
}
errMsg += "\n";
free(function);
}
free(stack_strings); // malloc()ed by backtrace_symbols
#endif
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(program && gameInitialized == true) {
//SystemFlags::Close();
printf("\nprogram->getState() [%p]\n",program->getState());
if(program->getState() != NULL) {
program->showMessage(errMsg.c_str());
for(;program->isMessageShowing();) {
//program->getState()->render();
Window::handleEvent();
program->loop();
}
}
else {
program->showMessage(errMsg.c_str());
for(;program->isMessageShowing();) {
//program->renderProgramMsgBox();
Window::handleEvent();
program->loop();
}
}
}
else {
string err = "#2 An error ocurred and " +
string(GameConstants::application_name) +
" will close.\nError msg = [" +
errMsg +
"]\n\nPlease report this bug to "+mailString;
#ifdef WIN32
err += string(", attaching the generated ") + getCrashDumpFileName() + string(" file.");
#endif
@ -213,10 +424,7 @@ public:
#ifdef WIN32
runtimeErrorMsg = "";
if(msg != NULL) {
runtimeErrorMsg = msg;
}
runtimeErrorMsg = errMsg;
throw runtimeErrorMsg;
#endif
//SystemFlags::Close();
@ -1277,7 +1485,7 @@ int glestMainWrapper(int argc, char** argv) {
#ifdef WIN32_STACK_TRACE
__try {
#endif
application_binary=argv[0];
return glestMain(argc, argv);
#ifdef WIN32_STACK_TRACE

View File

@ -601,6 +601,10 @@ void Program::restoreDisplaySettings(){
}
}
bool Program::isMessageShowing() {
return msgBox.getEnabled();
}
void Program::showMessage(const char *msg) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] msg [%s]\n",__FILE__,__FUNCTION__,__LINE__,msg);

View File

@ -145,6 +145,7 @@ public:
void loopWorker();
void resize(SizeState sizeState);
void showMessage(const char *msg);
bool isMessageShowing();
//misc
void setState(ProgramState *programState,bool cleanupOldState=true);

View File

@ -88,8 +88,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
}
catch(const std::exception &ex) {
serverInitError = true;
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//throw runtime_error(szBuf);!!!
@ -444,7 +444,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
}
if(results.size() == 0) {
throw runtime_error("(1)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
//throw 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()] + "]";
}
for(int i=0; i<GameConstants::maxPlayers; ++i){
@ -595,6 +597,7 @@ void MenuStateCustomGame::returnToParentMenu(){
void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
try {
CoreData &coreData= CoreData::getInstance();
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
int oldListBoxMapfilterIndex=listBoxMapFilter.getSelectedItemIndex();
@ -722,7 +725,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
else if (listBoxAdvanced.mouseClick(x, y)) {
//TODO
}
/*
/*
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableServerControlledAI.mouseClick(x, y) && listBoxEnableServerControlledAI.getEditable()) {
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
needToRepublishToMasterserver = true;
@ -733,7 +736,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
lastSetChangedGameSettings = time(NULL);
}
}
*/
*/
else if(listBoxTileset.mouseClick(x, y)){
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
@ -786,7 +789,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
needToRepublishToMasterserver = true;
soundRenderer.playFx(coreData.getClickSoundC());
}
/*
/*
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkFramePeriod.mouseClick(x, y)){
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
needToRepublishToMasterserver = true;
@ -798,7 +801,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
soundRenderer.playFx(coreData.getClickSoundC());
}
*/
*/
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)){
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
@ -917,6 +920,16 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
}
}
}
}
catch(const std::exception &ex) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//throw runtime_error(szBuf);
showGeneralError=true;
generalErrorToShow = szBuf;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -1356,8 +1369,8 @@ void MenuStateCustomGame::render() {
renderer.renderConsole(&console,showFullConsole,true);
}
catch(const std::exception &ex) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
throw runtime_error(szBuf);
}
}
@ -1770,8 +1783,8 @@ void MenuStateCustomGame::update() {
}
}
catch(const std::exception &ex) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//throw runtime_error(szBuf);
@ -1841,6 +1854,7 @@ void MenuStateCustomGame::publishToMasterserver()
void MenuStateCustomGame::simpleTask() {
try {
if(publishToMasterserverThreadInDeletion == true) {
return;
}
@ -1956,6 +1970,16 @@ void MenuStateCustomGame::simpleTask() {
serverInterface->broadcastPing(&msg);
safeMutex2.ReleaseLock();
}
}
catch(const std::exception &ex) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//throw runtime_error(szBuf);!!!
showGeneralError=true;
generalErrorToShow = ex.what();
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -2361,8 +2385,8 @@ bool MenuStateCustomGame::hasNetworkGameSettings() {
}
}
catch(const std::exception &ex) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
showGeneralError=true;
@ -2445,7 +2469,9 @@ void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem) {
}
if(results.size() == 0) {
throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
//throw 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()] + "]";
}
results.push_back(formatString(GameConstants::RANDOMFACTION_SLOTNAME));
@ -2512,8 +2538,8 @@ void MenuStateCustomGame::updateControlers(){
}
}
catch(const std::exception &ex) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
}
@ -2533,8 +2559,8 @@ void MenuStateCustomGame::closeUnusedSlots(){
updateNetworkSlots();
}
catch(const std::exception &ex) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw runtime_error(szBuf);
}
@ -2562,8 +2588,8 @@ void MenuStateCustomGame::updateNetworkSlots() {
serverInterface->addSlot(i);
}
catch(const std::exception &ex) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
showGeneralError=true;
@ -2585,8 +2611,8 @@ void MenuStateCustomGame::updateNetworkSlots() {
}
}
catch(const std::exception &ex) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//throw runtime_error(szBuf);!!!

View File

@ -535,9 +535,7 @@ void ClientInterface::updateKeyframe(int frameCount) {
NetworkMessageCommandList networkMessageCommandList;
while(receiveMessage(&networkMessageCommandList) == false &&
isConnected() == true &&
difftime(time(NULL),receiveTimeElapsed) <= (messageWaitTimeout / 1000)) {
//sleep(waitSleepTime);
//sleep(0);
difftime(time(NULL),receiveTimeElapsed) <= (messageWaitTimeout / 2000)) {
waitCount++;
}
@ -585,11 +583,9 @@ void ClientInterface::updateKeyframe(int frameCount) {
{
time_t receiveTimeElapsed = time(NULL);
NetworkMessageQuit networkMessageQuit;
//if(receiveMessage(&networkMessageQuit)) {
while(receiveMessage(&networkMessageQuit) == false &&
isConnected() == true &&
difftime(time(NULL),receiveTimeElapsed) <= (messageWaitTimeout / 1000)) {
//sleep(0);
difftime(time(NULL),receiveTimeElapsed) <= (messageWaitTimeout / 2000)) {
}
quit= true;
done= true;
@ -603,7 +599,6 @@ void ClientInterface::updateKeyframe(int frameCount) {
while(receiveMessage(&networkMessageText) == false &&
isConnected() == true &&
difftime(time(NULL),receiveTimeElapsed) <= (messageWaitTimeout / 1000)) {
//sleep(0);
}
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex());

View File

@ -344,8 +344,8 @@ void ConnectionSlot::update(bool checkForNewClients) {
lastReceiveCommandListTime = time(NULL);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] currentFrameCount = %d\n",__FILE__,__FUNCTION__,__LINE__,currentFrameCount);
for(int i= 0; i<networkMessageCommandList.getCommandCount(); ++i) {
MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,intToStr(__LINE__));
for(int i = 0; i < networkMessageCommandList.getCommandCount(); ++i) {
vctPendingNetworkCommandList.push_back(*networkMessageCommandList.getCommand(i));
}
}

View File

@ -305,7 +305,7 @@ void NetworkMessageLaunch::send(Socket* socket) const{
// class NetworkMessageLaunch
// =====================================================
NetworkMessageCommandList::NetworkMessageCommandList(int32 frameCount){
NetworkMessageCommandList::NetworkMessageCommandList(int32 frameCount) {
data.header.messageType= nmtCommandList;
data.header.frameCount= frameCount;
data.header.commandCount= 0;
@ -317,24 +317,29 @@ bool NetworkMessageCommandList::addCommand(const NetworkCommand* networkCommand)
data.header.commandCount++;
return true;
}
else {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR too many commands in commandlist data.header.commandCount = %d\n",__FILE__,__FUNCTION__,__LINE__,data.header.commandCount);
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] WARNING / ERROR too many commands in commandlist data.header.commandCount = %d\n",__FILE__,__FUNCTION__,__LINE__,data.header.commandCount);
}
return false;
}
bool NetworkMessageCommandList::receive(Socket* socket) {
// _peek_ type, commandCount & frame num first.
for(int peekAttempt = 1; peekAttempt < 1000; peekAttempt++) {
for(int peekAttempt = 1; peekAttempt < 2000; peekAttempt++) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] peekAttempt = %d\n",__FILE__,__FUNCTION__,__LINE__,peekAttempt);
if (NetworkMessage::peek(socket, &data, commandListHeaderSize) == true) {
break;
}
else {
sleep(1); // sleep 1 ms to wait for socket data
}
//else {
// sleep(1); // sleep 1 ms to wait for socket data
//}
}
if (NetworkMessage::peek(socket, &data, commandListHeaderSize) == false) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR / WARNING!!! NetworkMessage::peek failed!\n",__FILE__,__FUNCTION__,__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] ERROR / WARNING!!! NetworkMessage::peek failed!\n",__FILE__,__FUNCTION__,__LINE__);
return false;
}
@ -345,21 +350,24 @@ bool NetworkMessageCommandList::receive(Socket* socket) {
int totalMsgSize = commandListHeaderSize + (sizeof(NetworkCommand) * data.header.commandCount);
// _peek_ type, commandCount & frame num first.
for(int peekAttempt = 1; peekAttempt < 1000; peekAttempt++) {
for(int peekAttempt = 1; peekAttempt < 2000; peekAttempt++) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] peekAttempt = %d\n",__FILE__,__FUNCTION__,__LINE__,peekAttempt);
if (NetworkMessage::peek(socket, &data, totalMsgSize) == true) {
break;
}
else {
sleep(1); // sleep 1 ms to wait for socket data
}
//else {
// sleep(1); // sleep 1 ms to wait for socket data
//}
}
if (socket->getDataToRead() < totalMsgSize) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR / WARNING!!! Insufficient data to read entire command list [need %d bytes, only %d available].\n",
__FILE__,__FUNCTION__,__LINE__, totalMsgSize, socket->getDataToRead());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] ERROR / WARNING!!! Insufficient data to read entire command list [need %d bytes, only %d available].\n",
__FILE__,__FUNCTION__,__LINE__, totalMsgSize, socket->getDataToRead());
return false;
}
bool result = NetworkMessage::receive(socket, &data, totalMsgSize);
@ -374,7 +382,7 @@ bool NetworkMessageCommandList::receive(Socket* socket) {
return result;
}
void NetworkMessageCommandList::send(Socket* socket) const{
void NetworkMessageCommandList::send(Socket* socket) const {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] nmtCommandList, frameCount = %d, data.header.commandCount = %d, data.header.messageType = %d\n",__FILE__,__FUNCTION__,__LINE__,data.header.frameCount,data.header.commandCount,data.header.messageType);
assert(data.header.messageType==nmtCommandList);

View File

@ -242,15 +242,12 @@ public:
#pragma pack(push, 1)
class NetworkMessageCommandList: public NetworkMessage{
private:
//static const int maxCommandCount= 16*4;
//static const int maxCommandCount = (16 * 4) * 2;
static const int maxCommandCount = 2048; // can be as large as 65535
static const int maxCommandCount = 2496; // can be as large as 65535
private:
struct DataHeader {
int8 messageType;
uint16 commandCount;
//int8 commandCount;
int32 frameCount;
};

View File

@ -54,7 +54,7 @@ NetworkCommand::NetworkCommand(World *world, int networkCommandType, int unitId,
this->unitFactionIndex = unit->getFaction()->getIndex();
this->unitFactionUnitCount = unit->getFaction()->getUnitCount();
const UnitType *unitType= world->findUnitTypeById(unit->getFaction()->getType(), this->unitTypeId);
//const UnitType *unitType= world->findUnitTypeById(unit->getFaction()->getType(), this->unitTypeId);
const CommandType *ct = unit->getType()->findCommandTypeById(this->commandTypeId);
if(ct != NULL && ct->getClass() == ccBuild) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,toString().c_str());
@ -63,6 +63,8 @@ NetworkCommand::NetworkCommand(World *world, int networkCommandType, int unitId,
}
}
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Created NetworkCommand as follows:\n%s\n",__FILE__,__FUNCTION__,__LINE__,toString().c_str());
}
void NetworkCommand::preprocessNetworkCommand(World *world) {
@ -71,7 +73,7 @@ void NetworkCommand::preprocessNetworkCommand(World *world) {
//validate unit
if(unit != NULL) {
const UnitType *unitType= world->findUnitTypeById(unit->getFaction()->getType(), unitTypeId);
//const UnitType *unitType= world->findUnitTypeById(unit->getFaction()->getType(), unitTypeId);
const CommandType *ct = unit->getType()->findCommandTypeById(commandTypeId);
if(ct != NULL && ct->getClass() == ccBuild && targetId >= 0) {
CardinalDir::assertDirValid(targetId);
@ -94,16 +96,4 @@ string NetworkCommand::toString() const {
return result;
}
/*
NetworkCommand::NetworkCommand(int networkCommandType, NetworkCommandSubType ncstType, int unitId, int value1, int value2) {
this->networkCommandType= networkCommandType;
this->unitId= unitId;
this->commandTypeId= ncstType;
this->positionX= -1;
this->positionY= -1;
this->unitTypeId= value1;
this->targetId= value2;
}
*/
}}//end namespace

View File

@ -72,14 +72,14 @@ enum NetworkCommandType {
//};
#pragma pack(push, 1)
class NetworkCommand{
class NetworkCommand {
private:
int16 networkCommandType;
int32 unitId;
int16 unitTypeId;
int16 commandTypeId;
int16 positionX;
int16 positionY;
int16 unitTypeId;
int32 targetId;
int8 wantQueue;
int8 fromFactionIndex;

View File

@ -791,7 +791,7 @@ void ServerInterface::update() {
}
}
void ServerInterface::updateKeyframe(int frameCount){
void ServerInterface::updateKeyframe(int frameCount) {
Chrono chrono;
chrono.start();
@ -801,7 +801,7 @@ void ServerInterface::updateKeyframe(int frameCount){
NetworkMessageCommandList networkMessageCommandList(frameCount);
//build command list, remove commands from requested and add to pending
while(!requestedCommands.empty()) {
while(requestedCommands.empty() == false) {
if(networkMessageCommandList.addCommand(&requestedCommands.back())) {
pendingCommands.push_back(requestedCommands.back());
requestedCommands.pop_back();
@ -814,9 +814,10 @@ void ServerInterface::updateKeyframe(int frameCount){
try {
// Possible cause of out of synch since we have more commands that need
// to be sent in this frame
if(!requestedCommands.empty()) {
if(requestedCommands.empty() == false) {
char szBuf[1024]="";
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,requestedCommands.size());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,requestedCommands.size());
string sMsg = "may go out of synch: server requestedCommands.size() = " + intToStr(requestedCommands.size());
sendTextMessage(sMsg,-1, true);

View File

@ -31,7 +31,7 @@ const float SoundRenderer::audibleDist= 50.f;
// class SoundRenderer
// =====================================================
SoundRenderer::SoundRenderer(){
SoundRenderer::SoundRenderer() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
soundPlayer = NULL;
@ -49,7 +49,6 @@ bool SoundRenderer::init(Window *window) {
Config &config= Config::getInstance();
runThreadSafe = config.getBool("ThreadedSoundStream","false");
//if(soundPlayer == NULL) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
si.setFactory(fr.getSoundFactory(config.getString("FactorySound")));
@ -62,7 +61,6 @@ bool SoundRenderer::init(Window *window) {
soundPlayerParams.strBufferCount= config.getInt("SoundStreamingBuffers");
soundPlayer->init(&soundPlayerParams);
}
//}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -84,7 +82,7 @@ bool SoundRenderer::wasInitOk() const {
return result;
}
SoundRenderer::~SoundRenderer(){
SoundRenderer::~SoundRenderer() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
stopAllSounds();
@ -97,55 +95,63 @@ SoundRenderer::~SoundRenderer(){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
SoundRenderer &SoundRenderer::getInstance(){
SoundRenderer &SoundRenderer::getInstance() {
static SoundRenderer soundRenderer;
return soundRenderer;
}
void SoundRenderer::update(){
void SoundRenderer::update() {
if(soundPlayer != NULL) {
if(runThreadSafe == true) mutex.p();
MutexSafeWrapper safeMutex(NULL);
if(runThreadSafe == true) {
safeMutex.setMutex(&mutex);
}
soundPlayer->updateStreams();
if(runThreadSafe == true) mutex.v();
}
}
// ======================= Music ============================
void SoundRenderer::playMusic(StrSound *strSound){
void SoundRenderer::playMusic(StrSound *strSound) {
if(strSound != NULL) {
strSound->setVolume(musicVolume);
strSound->restart();
if(soundPlayer != NULL) {
if(runThreadSafe == true) mutex.p();
MutexSafeWrapper safeMutex(NULL);
if(runThreadSafe == true) {
safeMutex.setMutex(&mutex);
}
soundPlayer->play(strSound);
if(runThreadSafe == true) mutex.v();
}
}
}
void SoundRenderer::setMusicVolume(StrSound *strSound){
void SoundRenderer::setMusicVolume(StrSound *strSound) {
if(strSound != NULL) {
strSound->setVolume(musicVolume);
}
}
void SoundRenderer::stopMusic(StrSound *strSound){
void SoundRenderer::stopMusic(StrSound *strSound) {
if(soundPlayer != NULL) {
if(runThreadSafe == true) mutex.p();
MutexSafeWrapper safeMutex(NULL);
if(runThreadSafe == true) {
safeMutex.setMutex(&mutex);
}
soundPlayer->stop(strSound);
if(strSound != NULL) {
if(strSound->getNext() != NULL) {
soundPlayer->stop(strSound->getNext());
}
}
if(runThreadSafe == true) mutex.v();
}
}
// ======================= Fx ============================
void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPos){
void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPos) {
if(staticSound!=NULL){
float d= soundPos.dist(camPos);
@ -155,57 +161,72 @@ void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPo
staticSound->setVolume(correctedVol);
if(soundPlayer != NULL) {
if(runThreadSafe == true) mutex.p();
MutexSafeWrapper safeMutex(NULL);
if(runThreadSafe == true) {
safeMutex.setMutex(&mutex);
}
soundPlayer->play(staticSound);
if(runThreadSafe == true) mutex.v();
}
}
}
}
void SoundRenderer::playFx(StaticSound *staticSound){
void SoundRenderer::playFx(StaticSound *staticSound) {
if(staticSound!=NULL){
staticSound->setVolume(fxVolume);
if(soundPlayer != NULL) {
if(runThreadSafe == true) mutex.p();
MutexSafeWrapper safeMutex(NULL);
if(runThreadSafe == true) {
safeMutex.setMutex(&mutex);
}
soundPlayer->play(staticSound);
if(runThreadSafe == true) mutex.v();
}
}
}
// ======================= Ambient ============================
void SoundRenderer::playAmbient(StrSound *strSound){
void SoundRenderer::playAmbient(StrSound *strSound) {
if(strSound != NULL) {
strSound->setVolume(ambientVolume);
if(soundPlayer != NULL) {
if(runThreadSafe == true) mutex.p();
MutexSafeWrapper safeMutex(NULL);
if(runThreadSafe == true) {
safeMutex.setMutex(&mutex);
}
soundPlayer->play(strSound, ambientFade);
if(runThreadSafe == true) mutex.v();
}
}
}
void SoundRenderer::stopAmbient(StrSound *strSound){
void SoundRenderer::stopAmbient(StrSound *strSound) {
if(soundPlayer != NULL) {
if(runThreadSafe == true) mutex.p();
MutexSafeWrapper safeMutex(NULL);
if(runThreadSafe == true) {
safeMutex.setMutex(&mutex);
}
soundPlayer->stop(strSound, ambientFade);
if(runThreadSafe == true) mutex.v();
}
}
// ======================= Misc ============================
void SoundRenderer::stopAllSounds(){
void SoundRenderer::stopAllSounds() {
if(soundPlayer != NULL) {
mutex.p();
MutexSafeWrapper safeMutex(NULL);
if(runThreadSafe == true) {
safeMutex.setMutex(&mutex);
}
soundPlayer->stopAllSounds();
mutex.v();
}
}
void SoundRenderer::loadConfig(){
void SoundRenderer::loadConfig() {
Config &config= Config::getInstance();
fxVolume= config.getInt("SoundVolumeFx")/100.f;

View File

@ -71,7 +71,6 @@ public:
void playFx(StaticSound *staticSound);
//ambient
//void playAmbient(StaticSound *staticSound);
void playAmbient(StrSound *strSound);
void stopAmbient(StrSound *strSound);

View File

@ -36,7 +36,7 @@ Command::Command(const CommandType *ct, const Vec2i &pos){
stateValue = -1;
}
Command::Command(const CommandType *ct, Unit* unit){
Command::Command(const CommandType *ct, Unit* unit) {
this->commandType= ct;
this->pos= Vec2i(0);
this->unitRef= unit;
@ -49,7 +49,7 @@ Command::Command(const CommandType *ct, Unit* unit){
stateValue = -1;
}
Command::Command(const CommandType *ct, const Vec2i &pos, const UnitType *unitType, CardinalDir facing){
Command::Command(const CommandType *ct, const Vec2i &pos, const UnitType *unitType, CardinalDir facing) {
this->commandType= ct;
this->pos= pos;
this->unitRef= NULL;

View File

@ -1900,7 +1900,7 @@ std::string Unit::toString() const {
result += "id = " + intToStr(this->id);
if(this->type != NULL) {
result += " name [" + this->type->getName() + "]";
result += " name [" + this->type->getName() + "][" + intToStr(this->type->getId()) + "]";
}
if(this->faction != NULL) {

View File

@ -481,15 +481,23 @@ void SoundPlayerOpenAL::updateStreams() {
source->update();
}
catch(std::exception& e) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
std::cerr << "Error while updating sound stream: "
<< e.what() << "\n";
std::cerr << "Error while updating sound stream: "<< e.what() << "\n";
}
}
alcProcessContext(context);
checkAlcError("Error while processing audio context: ");
} catch(...) {
}
catch(exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
printOpenALInfo();
throw runtime_error(ex.what());
}
catch(...) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
printOpenALInfo();
throw;