- network code bugfixes.
- More checking for disconnect and proper handling of those cases - Changed battle end screen to exit via mouse click on exit button (or press ESC) - Removed display of unused ping output - added more error handling debug output of the mystical unknown error caught in window.cpp to track it down better if it happens again
This commit is contained in:
parent
12cd2e02d6
commit
aa0db2c0f0
|
@ -86,13 +86,26 @@ Game::~Game(){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
renderer.endGame();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
SoundRenderer::getInstance().stopAllSounds();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
NetworkManager::getInstance().end();
|
||||
sleep(15);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
deleteValues(aiInterfaces.begin(), aiInterfaces.end());
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
gui.end(); //selection must be cleared before deleting units
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
world.end(); //must die before selection because of referencers
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -101,6 +114,8 @@ Game::~Game(){
|
|||
if(originalDisplayMsgCallback != NULL) {
|
||||
NetworkInterface::setDisplayMessageFunction(originalDisplayMsgCallback);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
// ==================== init and load ====================
|
||||
|
@ -1068,8 +1083,6 @@ void Game::quitGame(){
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
NetworkManager::getInstance().end();
|
||||
|
||||
program->setState(new BattleEnd(program, &stats));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,19 +39,35 @@ BattleEnd::BattleEnd(Program *program, const Stats *stats): ProgramState(program
|
|||
if(stats != NULL) {
|
||||
this->stats= *stats;
|
||||
}
|
||||
mouseX = 0;
|
||||
mouseY = 0;
|
||||
mouse2d = 0;
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
Lang &lang= Lang::getInstance();
|
||||
int buttonWidth = 125;
|
||||
int xLocation = (metrics.getVirtualW() / 2) - (buttonWidth / 2);
|
||||
buttonExit.init(xLocation, 80, buttonWidth);
|
||||
buttonExit.setText(lang.get("Exit"));
|
||||
|
||||
//mesage box
|
||||
mainMessageBox.init(lang.get("Yes"), lang.get("No"));
|
||||
mainMessageBox.setEnabled(false);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
BattleEnd::~BattleEnd(){
|
||||
BattleEnd::~BattleEnd() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SoundRenderer::getInstance().playMusic(CoreData::getInstance().getMenuMusic());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void BattleEnd::update(){
|
||||
void BattleEnd::update() {
|
||||
if(Config::getInstance().getBool("AutoTest")){
|
||||
AutoTest::getInstance().updateBattleEnd(program);
|
||||
}
|
||||
mouse2d= (mouse2d+1) % Renderer::maxMouse2dAnim;
|
||||
}
|
||||
|
||||
void BattleEnd::render(){
|
||||
|
@ -148,17 +164,87 @@ void BattleEnd::render(){
|
|||
textRenderer->render(header, lm+250, bm+550);
|
||||
|
||||
textRenderer->end();
|
||||
|
||||
renderer.renderButton(&buttonExit);
|
||||
|
||||
//exit message box
|
||||
if(mainMessageBox.getEnabled()){
|
||||
renderer.renderMessageBox(&mainMessageBox);
|
||||
}
|
||||
|
||||
renderer.renderMouse2d(mouseX, mouseY, mouse2d, 0.f);
|
||||
|
||||
renderer.swapBuffers();
|
||||
}
|
||||
|
||||
void BattleEnd::keyDown(char key){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->setState(new MainMenu(program));
|
||||
if(key == vkEscape) {
|
||||
//program->setState(new MainMenu(program));
|
||||
|
||||
if(mainMessageBox.getEnabled()) {
|
||||
mainMessageBox.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
Lang &lang= Lang::getInstance();
|
||||
showMessageBox(lang.get("ExitGame?"), "", true);
|
||||
}
|
||||
}
|
||||
else if(key == vkReturn && mainMessageBox.getEnabled()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->setState(new MainMenu(program));
|
||||
}
|
||||
}
|
||||
|
||||
void BattleEnd::mouseDownLeft(int x, int y){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->setState(new MainMenu(program));
|
||||
//program->setState(new MainMenu(program));
|
||||
|
||||
if(buttonExit.mouseClick(x,y)) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->setState(new MainMenu(program));
|
||||
}
|
||||
else if(mainMessageBox.getEnabled()) {
|
||||
int button= 1;
|
||||
if(mainMessageBox.mouseClick(x, y, button)) {
|
||||
if(button==1) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->setState(new MainMenu(program));
|
||||
}
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//close message box
|
||||
mainMessageBox.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BattleEnd::mouseMove(int x, int y, const MouseState *ms){
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
|
||||
buttonExit.mouseMove(x, y);
|
||||
if (mainMessageBox.getEnabled()) {
|
||||
mainMessageBox.mouseMove(x, y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BattleEnd::showMessageBox(const string &text, const string &header, bool toggle) {
|
||||
if(toggle == false) {
|
||||
mainMessageBox.setEnabled(false);
|
||||
}
|
||||
|
||||
if(mainMessageBox.getEnabled() == false) {
|
||||
mainMessageBox.setText(text);
|
||||
mainMessageBox.setHeader(header);
|
||||
mainMessageBox.setEnabled(true);
|
||||
}
|
||||
else {
|
||||
mainMessageBox.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
50
source/glest_game/main/battle_end.h
Normal file
50
source/glest_game/main/battle_end.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _GLEST_GAME_BATTLEEND_H_
|
||||
#define _GLEST_GAME_BATTLEEND_H_
|
||||
|
||||
#include "program.h"
|
||||
#include "stats.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
// =====================================================
|
||||
// class BattleEnd
|
||||
//
|
||||
/// ProgramState representing the end of the game
|
||||
// =====================================================
|
||||
|
||||
class BattleEnd: public ProgramState{
|
||||
private:
|
||||
Stats stats;
|
||||
|
||||
GraphicButton buttonExit;
|
||||
int mouseX;
|
||||
int mouseY;
|
||||
int mouse2d;
|
||||
GraphicMessageBox mainMessageBox;
|
||||
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
|
||||
public:
|
||||
BattleEnd(Program *program, const Stats *stats);
|
||||
~BattleEnd();
|
||||
virtual void update();
|
||||
virtual void render();
|
||||
virtual void keyDown(char key);
|
||||
virtual void mouseDownLeft(int x, int y);
|
||||
virtual void mouseMove(int x, int y, const MouseState *ms);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
|
@ -387,9 +387,10 @@ void MenuStateConnectedGame::update()
|
|||
}
|
||||
|
||||
std::string networkFrameString = lang.get("NetworkFramePeriod") + " " + intToStr(clientInterface->getGameSettings()->getNetworkFramePeriod());
|
||||
float pingTime = clientInterface->getThreadedPingMS(clientInterface->getServerIpAddress().c_str());
|
||||
//float pingTime = clientInterface->getThreadedPingMS(clientInterface->getServerIpAddress().c_str());
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"%s, ping = %.2fms, %s",label.c_str(),pingTime,networkFrameString.c_str());
|
||||
//sprintf(szBuf,"%s, ping = %.2fms, %s",label.c_str(),pingTime,networkFrameString.c_str());
|
||||
sprintf(szBuf,"%s, %s",label.c_str(),networkFrameString.c_str());
|
||||
|
||||
labelStatus.setText(szBuf);
|
||||
}
|
||||
|
@ -429,9 +430,10 @@ void MenuStateConnectedGame::update()
|
|||
}
|
||||
|
||||
std::string networkFrameString = lang.get("NetworkFramePeriod") + " " + intToStr(clientInterface->getGameSettings()->getNetworkFramePeriod());
|
||||
float pingTime = clientInterface->getThreadedPingMS(clientInterface->getServerIpAddress().c_str());
|
||||
//float pingTime = clientInterface->getThreadedPingMS(clientInterface->getServerIpAddress().c_str());
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"%s, ping = %.2fms, %s",label.c_str(),pingTime,networkFrameString.c_str());
|
||||
//sprintf(szBuf,"%s, ping = %.2fms, %s",label.c_str(),pingTime,networkFrameString.c_str());
|
||||
sprintf(szBuf,"%s, %s",label.c_str(),networkFrameString.c_str());
|
||||
|
||||
labelStatus.setText(szBuf);
|
||||
}
|
||||
|
|
|
@ -887,9 +887,10 @@ void MenuStateCustomGame::update() {
|
|||
}
|
||||
}
|
||||
|
||||
float pingTime = connectionSlot->getThreadedPingMS(connectionSlot->getIpAddress().c_str());
|
||||
//float pingTime = connectionSlot->getThreadedPingMS(connectionSlot->getIpAddress().c_str());
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"%s, ping = %.2fms",label.c_str(),pingTime);
|
||||
//sprintf(szBuf,"%s, ping = %.2fms",label.c_str(),pingTime);
|
||||
sprintf(szBuf,"%s",label.c_str());
|
||||
|
||||
labelNetStatus[i].setText(szBuf);
|
||||
}
|
||||
|
|
|
@ -56,18 +56,26 @@ ClientInterface::ClientInterface(){
|
|||
|
||||
ClientInterface::~ClientInterface()
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(clientSocket != NULL && clientSocket->isConnected() == true)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
string sQuitText = Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + " has chosen to leave the game!";
|
||||
sendTextMessage(sQuitText,-1);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
close();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
delete clientSocket;
|
||||
clientSocket = NULL;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void ClientInterface::connect(const Ip &ip, int port)
|
||||
|
@ -708,9 +716,10 @@ void ClientInterface::sendTextMessage(const string &text, int teamIndex, bool ec
|
|||
|
||||
string ClientInterface::getNetworkStatus() {
|
||||
std::string label = Lang::getInstance().get("Server") + ": " + serverName;
|
||||
float pingTime = getThreadedPingMS(getServerIpAddress().c_str());
|
||||
//float pingTime = getThreadedPingMS(getServerIpAddress().c_str());
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"%s, ping = %.2fms",label.c_str(),pingTime);
|
||||
//sprintf(szBuf,"%s, ping = %.2fms",label.c_str(),pingTime);
|
||||
sprintf(szBuf,"%s",label.c_str());
|
||||
|
||||
return szBuf;
|
||||
}
|
||||
|
|
|
@ -460,17 +460,22 @@ void ServerInterface::update() {
|
|||
connectionSlot->clearThreadErrorList();
|
||||
}
|
||||
|
||||
connectionSlot = slots[i];
|
||||
|
||||
// Not done waiting for data yet
|
||||
bool updateFinished = connectionSlot->updateCompleted();
|
||||
bool updateFinished = (connectionSlot != NULL ? connectionSlot->updateCompleted() : true);
|
||||
if(updateFinished == false) {
|
||||
threadsDone = false;
|
||||
sleep(0);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
connectionSlot = slots[i];
|
||||
|
||||
// New lag check
|
||||
bool clientLagExceeded = false;
|
||||
if(gameHasBeenInitiated == true && connectionSlot->isConnected() == true) {
|
||||
if( gameHasBeenInitiated == true && connectionSlot != NULL &&
|
||||
connectionSlot->isConnected() == true) {
|
||||
clientLagExceeded = clientLagCheck(connectionSlot);
|
||||
}
|
||||
// If the client has exceeded lag and the server wants
|
||||
|
@ -550,7 +555,12 @@ void ServerInterface::update() {
|
|||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after connectionSlot->clearChatInfo chatText [%s] chatSender [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,chatText.c_str(),chatSender.c_str(),chatTeamIndex);
|
||||
}
|
||||
connectionSlot->clearChatInfo();
|
||||
|
||||
// Its possible that the slot is disconnected here
|
||||
// so check the original pointer again
|
||||
if(slots[i] != NULL) {
|
||||
connectionSlot->clearChatInfo();
|
||||
}
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
|
@ -570,9 +580,9 @@ void ServerInterface::update() {
|
|||
|
||||
if(connectionSlot!= NULL &&
|
||||
(gameHasBeenInitiated == false || (connectionSlot->getSocket() != NULL && socketTriggeredList[connectionSlot->getSocket()->getSocketId()] == true))) {
|
||||
if(connectionSlot->isConnected() && socketTriggeredList[connectionSlot->getSocket()->getSocketId()] == true) {
|
||||
if(connectionSlot->getSocket() != NULL) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] calling connectionSlot->getNextMessageType() for slots[i]->getSocket()->getSocketId() = %d\n",
|
||||
__FILE__,__FUNCTION__,connectionSlot->getSocket()->getSocketId());
|
||||
if( connectionSlot->isConnected() &&
|
||||
socketTriggeredList[connectionSlot->getSocket()->getSocketId()] == true) {
|
||||
if(connectionSlot->getSocket() != NULL) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] calling connectionSlot->getNextMessageType() for slots[i]->getSocket()->getSocketId() = %d\n",__FILE__,__FUNCTION__,connectionSlot->getSocket()->getSocketId());
|
||||
|
||||
try {
|
||||
if(connectionSlot->getNextMessageType() == nmtText) {
|
||||
|
@ -886,9 +896,10 @@ string ServerInterface::getNetworkStatus() {
|
|||
if(connectionSlot->isConnected()){
|
||||
int clientLagCount = connectionSlot->getCurrentLagCount();
|
||||
double lastClientCommandListTimeLag = difftime(time(NULL),connectionSlot->getLastReceiveCommandListTime());
|
||||
float pingTime = connectionSlot->getThreadedPingMS(connectionSlot->getIpAddress().c_str());
|
||||
//float pingTime = connectionSlot->getThreadedPingMS(connectionSlot->getIpAddress().c_str());
|
||||
char szBuf[100]="";
|
||||
sprintf(szBuf,", lag = %d [%.2f], ping = %.2fms",clientLagCount,lastClientCommandListTimeLag,pingTime);
|
||||
//sprintf(szBuf,", lag = %d [%.2f], ping = %.2fms",clientLagCount,lastClientCommandListTimeLag,pingTime);
|
||||
sprintf(szBuf,", lag = %d [%.2f]",clientLagCount,lastClientCommandListTimeLag);
|
||||
|
||||
str+= connectionSlot->getName() + string(szBuf);
|
||||
}
|
||||
|
|
|
@ -87,16 +87,19 @@ Window::~Window() {
|
|||
|
||||
bool Window::handleEvent() {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
string codeLocation = "a";
|
||||
|
||||
SDL_Event event;
|
||||
SDL_GetMouseState(&oldX,&oldY);
|
||||
|
||||
codeLocation = "b";
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
while(SDL_PollEvent(&event)) {
|
||||
try {
|
||||
//printf("START [%d]\n",event.type);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
codeLocation = "c";
|
||||
|
||||
switch(event.type) {
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
|
@ -104,25 +107,32 @@ bool Window::handleEvent() {
|
|||
case SDL_MOUSEMOTION:
|
||||
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
codeLocation = "d";
|
||||
|
||||
setLastMouseEvent(Chrono::getCurMillis());
|
||||
setMousePos(Vec2i(event.button.x, event.button.y));
|
||||
break;
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
codeLocation = "d";
|
||||
|
||||
switch(event.type) {
|
||||
case SDL_QUIT:
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
codeLocation = "e";
|
||||
return false;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
codeLocation = "f";
|
||||
|
||||
if(global_window) {
|
||||
global_window->handleMouseDown(event);
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP: {
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
codeLocation = "g";
|
||||
if(global_window) {
|
||||
MouseButton b = getMouseButton(event.button.button);
|
||||
setMouseState(b, false);
|
||||
|
@ -138,6 +148,8 @@ bool Window::handleEvent() {
|
|||
//ms.leftMouse = (event.motion.state & SDL_BUTTON_LMASK) != 0;
|
||||
//ms.rightMouse = (event.motion.state & SDL_BUTTON_RMASK) != 0;
|
||||
//ms.centerMouse = (event.motion.state & SDL_BUTTON_MMASK) != 0;
|
||||
codeLocation = "h";
|
||||
|
||||
setMouseState(mbLeft, event.motion.state & SDL_BUTTON_LMASK);
|
||||
setMouseState(mbRight, event.motion.state & SDL_BUTTON_RMASK);
|
||||
setMouseState(mbCenter, event.motion.state & SDL_BUTTON_MMASK);
|
||||
|
@ -150,6 +162,7 @@ bool Window::handleEvent() {
|
|||
case SDL_KEYDOWN:
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
codeLocation = "i";
|
||||
Window::isKeyPressedDown = true;
|
||||
keystate = event.key.keysym;
|
||||
/* handle ALT+Return */
|
||||
|
@ -170,6 +183,8 @@ bool Window::handleEvent() {
|
|||
case SDL_KEYUP:
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
codeLocation = "j";
|
||||
|
||||
Window::isKeyPressedDown = false;
|
||||
keystate = event.key.keysym;
|
||||
|
||||
|
@ -178,7 +193,8 @@ bool Window::handleEvent() {
|
|||
}
|
||||
break;
|
||||
case SDL_ACTIVEEVENT:
|
||||
{
|
||||
{
|
||||
codeLocation = "k";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// Check if the program has lost keyboard focus
|
||||
|
@ -234,17 +250,17 @@ bool Window::handleEvent() {
|
|||
}
|
||||
}
|
||||
catch(std::runtime_error& e) {
|
||||
std::cerr << "(a) Couldn't process event: " << e.what() << "\n";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (a) Couldn't process event: [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
std::cerr << "(a) Couldn't process event: " << e.what() << " codelocation = " << codeLocation << "\n";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (a) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str());
|
||||
throw runtime_error(e.what());
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
std::cerr << "(b) Couldn't process event: " << e.what() << "\n";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (b) Couldn't process event: [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
std::cerr << "(b) Couldn't process event: " << e.what() << " codelocation = " << codeLocation << "\n";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (b) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str());
|
||||
}
|
||||
catch(...) {
|
||||
std::cerr << "(b) Couldn't process event: [UNKNOWN ERROR]\n";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (b) Couldn't process event: [UNKNOWN ERROR]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
std::cerr << "(c) Couldn't process event: [UNKNOWN ERROR] " << " codelocation = " << codeLocation << "\n";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (b) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str());
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
Loading…
Reference in New Issue
Block a user