mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 13:23:59 +02:00
- 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:
@@ -86,13 +86,26 @@ Game::~Game(){
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
renderer.endGame();
|
renderer.endGame();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
SoundRenderer::getInstance().stopAllSounds();
|
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());
|
deleteValues(aiInterfaces.begin(), aiInterfaces.end());
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
gui.end(); //selection must be cleared before deleting units
|
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
|
world.end(); //must die before selection because of referencers
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -101,6 +114,8 @@ Game::~Game(){
|
|||||||
if(originalDisplayMsgCallback != NULL) {
|
if(originalDisplayMsgCallback != NULL) {
|
||||||
NetworkInterface::setDisplayMessageFunction(originalDisplayMsgCallback);
|
NetworkInterface::setDisplayMessageFunction(originalDisplayMsgCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== init and load ====================
|
// ==================== init and load ====================
|
||||||
@@ -1068,8 +1083,6 @@ void Game::quitGame(){
|
|||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
NetworkManager::getInstance().end();
|
|
||||||
|
|
||||||
program->setState(new BattleEnd(program, &stats));
|
program->setState(new BattleEnd(program, &stats));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -39,19 +39,35 @@ BattleEnd::BattleEnd(Program *program, const Stats *stats): ProgramState(program
|
|||||||
if(stats != NULL) {
|
if(stats != NULL) {
|
||||||
this->stats= *stats;
|
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__);
|
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__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
SoundRenderer::getInstance().playMusic(CoreData::getInstance().getMenuMusic());
|
SoundRenderer::getInstance().playMusic(CoreData::getInstance().getMenuMusic());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleEnd::update(){
|
void BattleEnd::update() {
|
||||||
if(Config::getInstance().getBool("AutoTest")){
|
if(Config::getInstance().getBool("AutoTest")){
|
||||||
AutoTest::getInstance().updateBattleEnd(program);
|
AutoTest::getInstance().updateBattleEnd(program);
|
||||||
}
|
}
|
||||||
|
mouse2d= (mouse2d+1) % Renderer::maxMouse2dAnim;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleEnd::render(){
|
void BattleEnd::render(){
|
||||||
@@ -148,17 +164,87 @@ void BattleEnd::render(){
|
|||||||
textRenderer->render(header, lm+250, bm+550);
|
textRenderer->render(header, lm+250, bm+550);
|
||||||
|
|
||||||
textRenderer->end();
|
textRenderer->end();
|
||||||
|
|
||||||
|
renderer.renderButton(&buttonExit);
|
||||||
|
|
||||||
|
//exit message box
|
||||||
|
if(mainMessageBox.getEnabled()){
|
||||||
|
renderer.renderMessageBox(&mainMessageBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.renderMouse2d(mouseX, mouseY, mouse2d, 0.f);
|
||||||
|
|
||||||
renderer.swapBuffers();
|
renderer.swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleEnd::keyDown(char key){
|
void BattleEnd::keyDown(char key){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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){
|
void BattleEnd::mouseDownLeft(int x, int y){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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
|
}}//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());
|
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]="";
|
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);
|
labelStatus.setText(szBuf);
|
||||||
}
|
}
|
||||||
@@ -429,9 +430,10 @@ void MenuStateConnectedGame::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string networkFrameString = lang.get("NetworkFramePeriod") + " " + intToStr(clientInterface->getGameSettings()->getNetworkFramePeriod());
|
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]="";
|
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);
|
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]="";
|
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);
|
labelNetStatus[i].setText(szBuf);
|
||||||
}
|
}
|
||||||
|
@@ -56,18 +56,26 @@ ClientInterface::ClientInterface(){
|
|||||||
|
|
||||||
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)
|
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!";
|
string sQuitText = Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + " has chosen to leave the game!";
|
||||||
sendTextMessage(sQuitText,-1);
|
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;
|
delete clientSocket;
|
||||||
clientSocket = NULL;
|
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)
|
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() {
|
string ClientInterface::getNetworkStatus() {
|
||||||
std::string label = Lang::getInstance().get("Server") + ": " + serverName;
|
std::string label = Lang::getInstance().get("Server") + ": " + serverName;
|
||||||
float pingTime = getThreadedPingMS(getServerIpAddress().c_str());
|
//float pingTime = getThreadedPingMS(getServerIpAddress().c_str());
|
||||||
char szBuf[1024]="";
|
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;
|
return szBuf;
|
||||||
}
|
}
|
||||||
|
@@ -460,17 +460,22 @@ void ServerInterface::update() {
|
|||||||
connectionSlot->clearThreadErrorList();
|
connectionSlot->clearThreadErrorList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectionSlot = slots[i];
|
||||||
|
|
||||||
// Not done waiting for data yet
|
// Not done waiting for data yet
|
||||||
bool updateFinished = connectionSlot->updateCompleted();
|
bool updateFinished = (connectionSlot != NULL ? connectionSlot->updateCompleted() : true);
|
||||||
if(updateFinished == false) {
|
if(updateFinished == false) {
|
||||||
threadsDone = false;
|
threadsDone = false;
|
||||||
sleep(0);
|
sleep(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
connectionSlot = slots[i];
|
||||||
|
|
||||||
// New lag check
|
// New lag check
|
||||||
bool clientLagExceeded = false;
|
bool clientLagExceeded = false;
|
||||||
if(gameHasBeenInitiated == true && connectionSlot->isConnected() == true) {
|
if( gameHasBeenInitiated == true && connectionSlot != NULL &&
|
||||||
|
connectionSlot->isConnected() == true) {
|
||||||
clientLagExceeded = clientLagCheck(connectionSlot);
|
clientLagExceeded = clientLagCheck(connectionSlot);
|
||||||
}
|
}
|
||||||
// If the client has exceeded lag and the server wants
|
// 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);
|
//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) {
|
catch(const exception &ex) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
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 &&
|
if(connectionSlot!= NULL &&
|
||||||
(gameHasBeenInitiated == false || (connectionSlot->getSocket() != NULL && socketTriggeredList[connectionSlot->getSocket()->getSocketId()] == true))) {
|
(gameHasBeenInitiated == false || (connectionSlot->getSocket() != NULL && socketTriggeredList[connectionSlot->getSocket()->getSocketId()] == true))) {
|
||||||
if(connectionSlot->isConnected() && socketTriggeredList[connectionSlot->getSocket()->getSocketId()] == true) {
|
if( connectionSlot->isConnected() &&
|
||||||
if(connectionSlot->getSocket() != NULL) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] calling connectionSlot->getNextMessageType() for slots[i]->getSocket()->getSocketId() = %d\n",
|
socketTriggeredList[connectionSlot->getSocket()->getSocketId()] == true) {
|
||||||
__FILE__,__FUNCTION__,connectionSlot->getSocket()->getSocketId());
|
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 {
|
try {
|
||||||
if(connectionSlot->getNextMessageType() == nmtText) {
|
if(connectionSlot->getNextMessageType() == nmtText) {
|
||||||
@@ -886,9 +896,10 @@ string ServerInterface::getNetworkStatus() {
|
|||||||
if(connectionSlot->isConnected()){
|
if(connectionSlot->isConnected()){
|
||||||
int clientLagCount = connectionSlot->getCurrentLagCount();
|
int clientLagCount = connectionSlot->getCurrentLagCount();
|
||||||
double lastClientCommandListTimeLag = difftime(time(NULL),connectionSlot->getLastReceiveCommandListTime());
|
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]="";
|
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);
|
str+= connectionSlot->getName() + string(szBuf);
|
||||||
}
|
}
|
||||||
|
@@ -87,16 +87,19 @@ Window::~Window() {
|
|||||||
|
|
||||||
bool Window::handleEvent() {
|
bool Window::handleEvent() {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
string codeLocation = "a";
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_GetMouseState(&oldX,&oldY);
|
SDL_GetMouseState(&oldX,&oldY);
|
||||||
|
|
||||||
|
codeLocation = "b";
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
while(SDL_PollEvent(&event)) {
|
while(SDL_PollEvent(&event)) {
|
||||||
try {
|
try {
|
||||||
//printf("START [%d]\n",event.type);
|
//printf("START [%d]\n",event.type);
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
codeLocation = "c";
|
||||||
|
|
||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
@@ -104,25 +107,32 @@ bool Window::handleEvent() {
|
|||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
|
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
codeLocation = "d";
|
||||||
|
|
||||||
setLastMouseEvent(Chrono::getCurMillis());
|
setLastMouseEvent(Chrono::getCurMillis());
|
||||||
setMousePos(Vec2i(event.button.x, event.button.y));
|
setMousePos(Vec2i(event.button.x, event.button.y));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
codeLocation = "d";
|
||||||
|
|
||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
codeLocation = "e";
|
||||||
return false;
|
return false;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
codeLocation = "f";
|
||||||
|
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
global_window->handleMouseDown(event);
|
global_window->handleMouseDown(event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP: {
|
case SDL_MOUSEBUTTONUP: {
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
codeLocation = "g";
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
MouseButton b = getMouseButton(event.button.button);
|
MouseButton b = getMouseButton(event.button.button);
|
||||||
setMouseState(b, false);
|
setMouseState(b, false);
|
||||||
@@ -138,6 +148,8 @@ bool Window::handleEvent() {
|
|||||||
//ms.leftMouse = (event.motion.state & SDL_BUTTON_LMASK) != 0;
|
//ms.leftMouse = (event.motion.state & SDL_BUTTON_LMASK) != 0;
|
||||||
//ms.rightMouse = (event.motion.state & SDL_BUTTON_RMASK) != 0;
|
//ms.rightMouse = (event.motion.state & SDL_BUTTON_RMASK) != 0;
|
||||||
//ms.centerMouse = (event.motion.state & SDL_BUTTON_MMASK) != 0;
|
//ms.centerMouse = (event.motion.state & SDL_BUTTON_MMASK) != 0;
|
||||||
|
codeLocation = "h";
|
||||||
|
|
||||||
setMouseState(mbLeft, event.motion.state & SDL_BUTTON_LMASK);
|
setMouseState(mbLeft, event.motion.state & SDL_BUTTON_LMASK);
|
||||||
setMouseState(mbRight, event.motion.state & SDL_BUTTON_RMASK);
|
setMouseState(mbRight, event.motion.state & SDL_BUTTON_RMASK);
|
||||||
setMouseState(mbCenter, event.motion.state & SDL_BUTTON_MMASK);
|
setMouseState(mbCenter, event.motion.state & SDL_BUTTON_MMASK);
|
||||||
@@ -150,6 +162,7 @@ bool Window::handleEvent() {
|
|||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
codeLocation = "i";
|
||||||
Window::isKeyPressedDown = true;
|
Window::isKeyPressedDown = true;
|
||||||
keystate = event.key.keysym;
|
keystate = event.key.keysym;
|
||||||
/* handle ALT+Return */
|
/* handle ALT+Return */
|
||||||
@@ -170,6 +183,8 @@ bool Window::handleEvent() {
|
|||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
codeLocation = "j";
|
||||||
|
|
||||||
Window::isKeyPressedDown = false;
|
Window::isKeyPressedDown = false;
|
||||||
keystate = event.key.keysym;
|
keystate = event.key.keysym;
|
||||||
|
|
||||||
@@ -178,7 +193,8 @@ bool Window::handleEvent() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_ACTIVEEVENT:
|
case SDL_ACTIVEEVENT:
|
||||||
{
|
{
|
||||||
|
codeLocation = "k";
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT.\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
// Check if the program has lost keyboard focus
|
// Check if the program has lost keyboard focus
|
||||||
@@ -234,17 +250,17 @@ bool Window::handleEvent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(std::runtime_error& e) {
|
catch(std::runtime_error& e) {
|
||||||
std::cerr << "(a) Couldn't process event: " << e.what() << "\n";
|
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]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
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());
|
throw runtime_error(e.what());
|
||||||
}
|
}
|
||||||
catch(std::exception& e) {
|
catch(std::exception& e) {
|
||||||
std::cerr << "(b) Couldn't process event: " << e.what() << "\n";
|
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]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
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(...) {
|
catch(...) {
|
||||||
std::cerr << "(b) Couldn't process event: [UNKNOWN ERROR]\n";
|
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]\n",__FILE__,__FUNCTION__,__LINE__);
|
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__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
Reference in New Issue
Block a user