more user friendly error handling, try to display most errors in a nice messagebox in-game
This commit is contained in:
parent
3fdc1d2a18
commit
b31531db1f
|
@ -398,11 +398,14 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const{
|
|||
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!");
|
||||
|
||||
//validate command type
|
||||
if(ct == NULL) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s Line: %d] Can not find command type for\nnetwork command = [%s]\n%s\n in unit = %d [%s][%s].\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());
|
||||
sprintf(szBuf,"In [%s::%s Line: %d]\nCan not find command type 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::debugSystem,"%s\n",szBuf);
|
||||
|
||||
|
|
|
@ -376,6 +376,8 @@ void Game::simpleTask() {
|
|||
void Game::update(){
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
try {
|
||||
|
||||
// a) Updates non dependent on speed
|
||||
|
||||
//misc
|
||||
|
@ -446,6 +448,13 @@ void Game::update(){
|
|||
//throw runtime_error("Test!");
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::updateCamera(){
|
||||
|
@ -514,6 +523,7 @@ void Game::tick(){
|
|||
|
||||
void Game::mouseDownLeft(int x, int y){
|
||||
|
||||
try {
|
||||
Map *map= world.getMap();
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
|
@ -578,17 +588,41 @@ void Game::mouseDownLeft(int x, int y){
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::mouseDownRight(int x, int y){
|
||||
try {
|
||||
gui.mouseDownRightGraphics(x, y);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::mouseUpLeft(int x, int y){
|
||||
try {
|
||||
gui.mouseUpLeftGraphics(x, y);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::mouseDoubleClickLeft(int x, int y){
|
||||
try {
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
||||
//display panel
|
||||
|
@ -602,9 +636,17 @@ void Game::mouseDoubleClickLeft(int x, int y){
|
|||
|
||||
//graphics panel
|
||||
gui.mouseDoubleClickLeftGraphics(x, y);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::mouseMove(int x, int y, const MouseState *ms){
|
||||
try {
|
||||
const Metrics &metrics = Metrics::getInstance();
|
||||
|
||||
mouseX = x;
|
||||
|
@ -682,17 +724,32 @@ void Game::mouseMove(int x, int y, const MouseState *ms){
|
|||
|
||||
lastMousePos.x = mouseX;
|
||||
lastMousePos.y = mouseY;
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::eventMouseWheel(int x, int y, int zDelta) {
|
||||
try {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//gameCamera.transitionXYZ(0.0f, -(float)zDelta / 30.0f, 0.0f);
|
||||
gameCamera.zoom((float)zDelta / 60.0f);
|
||||
//gameCamera.setMoveY(1);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::keyDown(char key){
|
||||
|
||||
try {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -830,10 +887,17 @@ void Game::keyDown(char key){
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::keyUp(char key){
|
||||
|
||||
try {
|
||||
if(chatManager.getEditEnabled()){
|
||||
//send key to the chat manager
|
||||
chatManager.keyUp(key);
|
||||
|
@ -867,6 +931,13 @@ void Game::keyUp(char key){
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||
ErrorDisplayMessage(ex.what(),true);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::keyPress(char c){
|
||||
|
|
Loading…
Reference in New Issue