- added more bug fixes related to network disconnects.
- Added a new global message box to display error messages on top of any graphics window being displayed.
This commit is contained in:
parent
ff21d26161
commit
ab655162cb
|
@ -154,7 +154,7 @@ void ChatManager::updateNetwork() {
|
|||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameNetworkInterface->getChatText() [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameNetworkInterface->getChatText().c_str());
|
||||
|
||||
if(gameNetworkInterface->getChatTextList().empty() == false) {
|
||||
if(gameNetworkInterface != NULL && gameNetworkInterface->getChatTextList().empty() == false) {
|
||||
for(int idx = 0; idx < gameNetworkInterface->getChatTextList().size(); idx++) {
|
||||
const ChatMsgInfo &msg = gameNetworkInterface->getChatTextList()[idx];
|
||||
int teamIndex= msg.chatTeamIndex;
|
||||
|
|
|
@ -1235,6 +1235,7 @@ void Game::render2d(){
|
|||
Vec3f(1.0f), 200, 680, false);
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
|
||||
renderer.renderChatManager(&chatManager);
|
||||
|
||||
|
|
|
@ -133,6 +133,9 @@ void Intro::render(){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
|
||||
renderer.swapBuffers();
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
}
|
||||
|
||||
static int DisplayMessage(const char *msg, bool exitApp) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,msg);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
||||
|
||||
Program *program = Program::getInstance();
|
||||
if(program && gameInitialized == true) {
|
||||
|
@ -130,6 +130,20 @@ void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
|||
throw runtime_error("In [MainWindow::eventMouseDown] ERROR, program == NULL!");
|
||||
}
|
||||
|
||||
switch(mouseButton) {
|
||||
case mbLeft:
|
||||
program->mouseDownLeft(vx, vy);
|
||||
break;
|
||||
case mbRight:
|
||||
//program->mouseDownRight(vx, vy);
|
||||
break;
|
||||
case mbCenter:
|
||||
//program->mouseDownCenter(vx, vy);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ProgramState *programState = program->getState();
|
||||
if(programState != NULL) {
|
||||
switch(mouseButton) {
|
||||
|
@ -215,6 +229,8 @@ void MainWindow::eventMouseMove(int x, int y, const MouseState *ms){
|
|||
throw runtime_error("In [MainWindow::eventMouseMove] ERROR, program == NULL!");
|
||||
}
|
||||
|
||||
program->eventMouseMove(vx, vy, ms);
|
||||
|
||||
ProgramState *programState = program->getState();
|
||||
if(programState != NULL) {
|
||||
programState->mouseMove(vx, vy, ms);
|
||||
|
|
|
@ -120,6 +120,11 @@ Program::Program() {
|
|||
programState= NULL;
|
||||
singleton = this;
|
||||
soundThreadManager = NULL;
|
||||
|
||||
//mesage box
|
||||
Lang &lang= Lang::getInstance();
|
||||
msgBox.init(lang.get("Ok"));
|
||||
msgBox.setEnabled(false);
|
||||
}
|
||||
|
||||
void Program::initNormal(WindowGl *window){
|
||||
|
@ -168,6 +173,15 @@ Program::~Program(){
|
|||
}
|
||||
|
||||
void Program::keyDown(char key){
|
||||
|
||||
if(msgBox.getEnabled()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(key == vkEscape || key == vkReturn) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
msgBox.setEnabled(false);
|
||||
|
||||
}
|
||||
}
|
||||
//delegate event
|
||||
programState->keyDown(key);
|
||||
}
|
||||
|
@ -180,6 +194,23 @@ void Program::keyPress(char c){
|
|||
programState->keyPress(c);
|
||||
}
|
||||
|
||||
void Program::mouseDownLeft(int x, int y) {
|
||||
if(msgBox.getEnabled()) {
|
||||
int button= 1;
|
||||
if(msgBox.mouseClick(x, y, button)) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//close message box
|
||||
msgBox.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Program::eventMouseMove(int x, int y, const MouseState *ms) {
|
||||
if (msgBox.getEnabled()) {
|
||||
msgBox.mouseMove(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void Program::simpleTask() {
|
||||
loopWorker();
|
||||
}
|
||||
|
@ -189,21 +220,27 @@ void Program::loop() {
|
|||
}
|
||||
|
||||
void Program::loopWorker() {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] programState = %p\n",__FILE__,__FUNCTION__,__LINE__,programState);
|
||||
|
||||
Chrono chrono;
|
||||
chrono.start();
|
||||
|
||||
//getWindow()->makeCurrentGl();
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//render
|
||||
assert(programState != NULL);
|
||||
|
||||
ProgramState *prevState = this->programState;
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
programState->render();
|
||||
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
||||
//update camera
|
||||
chrono.start();
|
||||
while(updateCameraTimer.isTime()){
|
||||
|
@ -216,36 +253,44 @@ void Program::loopWorker() {
|
|||
|
||||
//update world
|
||||
chrono.start();
|
||||
while(updateTimer.isTime()){
|
||||
|
||||
while(prevState == this->programState && updateTimer.isTime()) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
GraphicComponent::update();
|
||||
programState->update();
|
||||
if(prevState == this->programState) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(soundThreadManager == NULL) {
|
||||
SoundRenderer::getInstance().update();
|
||||
}
|
||||
|
||||
if(soundThreadManager == NULL) {
|
||||
SoundRenderer::getInstance().update();
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
NetworkManager::getInstance().update();
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
NetworkManager::getInstance().update();
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//fps timer
|
||||
chrono.start();
|
||||
while(fpsTimer.isTime()){
|
||||
programState->tick();
|
||||
if(prevState == this->programState) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//fps timer
|
||||
chrono.start();
|
||||
while(fpsTimer.isTime()) {
|
||||
programState->tick();
|
||||
}
|
||||
|
||||
//if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
}
|
||||
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Program::resize(SizeState sizeState){
|
||||
|
@ -264,18 +309,12 @@ void Program::resize(SizeState sizeState){
|
|||
|
||||
// ==================== misc ====================
|
||||
|
||||
//Your filter function should look something like:
|
||||
int SDLEventFilter(const SDL_Event* filterEvent) {
|
||||
if(filterEvent->type == SDL_KEYDOWN || /**< Keys pressed */
|
||||
filterEvent->type == SDL_KEYUP || /**< Keys released */
|
||||
filterEvent->type == SDL_MOUSEMOTION || /**< Mouse moved */
|
||||
filterEvent->type == SDL_MOUSEBUTTONDOWN || /**< Mouse button pressed */
|
||||
filterEvent->type == SDL_MOUSEBUTTONUP) /**< Mouse button released */
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
void Program::renderProgramMsgBox() {
|
||||
if(msgBox.getEnabled()) {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.renderMessageBox(&msgBox);
|
||||
}
|
||||
}
|
||||
|
||||
void Program::setState(ProgramState *programState, bool cleanupOldState)
|
||||
{
|
||||
|
@ -309,6 +348,11 @@ void Program::setState(ProgramState *programState, bool cleanupOldState)
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//mesage box
|
||||
Lang &lang= Lang::getInstance();
|
||||
msgBox.init(lang.get("Ok"));
|
||||
msgBox.setEnabled(false);
|
||||
|
||||
this->programState= programState;
|
||||
programState->load();
|
||||
|
||||
|
@ -481,7 +525,15 @@ void Program::restoreDisplaySettings(){
|
|||
}
|
||||
|
||||
void Program::showMessage(const char *msg) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] msg [%s]\n",__FILE__,__FUNCTION__,__LINE__,msg);
|
||||
|
||||
msgBox.setText(msg);
|
||||
//msgBox.setHeader(header);
|
||||
msgBox.setEnabled(true);
|
||||
|
||||
|
||||
/*
|
||||
int showMouseState = SDL_ShowCursor(SDL_QUERY);
|
||||
|
||||
ProgramState *originalState = NULL;
|
||||
if(this->programState) {
|
||||
|
@ -491,17 +543,15 @@ void Program::showMessage(const char *msg) {
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
showCursor(true);
|
||||
|
||||
//SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
|
||||
ShowMessageProgramState *showMsg = new ShowMessageProgramState(this, msg);
|
||||
//this->programState = showMsg;
|
||||
|
||||
this->programState = NULL;
|
||||
setState(showMsg);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
showCursor(true);
|
||||
|
||||
while(Window::handleEvent() && showMsg->wantExit() == false) {
|
||||
loop();
|
||||
}
|
||||
|
@ -514,13 +564,11 @@ void Program::showMessage(const char *msg) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
if(config.getBool("No2DMouseRendering","false") == false) {
|
||||
showCursor(false);
|
||||
}
|
||||
//if(config.getBool("No2DMouseRendering","false") == false) {
|
||||
showCursor((showMouseState == SDL_ENABLE));
|
||||
//}
|
||||
|
||||
//MainWindow *mainWindow= new MainWindow(this);
|
||||
init(this->window,false);
|
||||
//setState(originalState);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
|
||||
|
||||
|
@ -529,20 +577,9 @@ void Program::showMessage(const char *msg) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->programState= originalState;
|
||||
//programState->load();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//programState->init();
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//updateTimer.reset();
|
||||
//updateCameraTimer.reset();
|
||||
//fpsTimer.reset();
|
||||
|
||||
|
||||
//this->programState = originalState;
|
||||
*/
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
|
|
@ -116,6 +116,8 @@ private:
|
|||
WindowGl *window;
|
||||
static Program *singleton;
|
||||
|
||||
GraphicMessageBox msgBox;
|
||||
|
||||
public:
|
||||
Program();
|
||||
~Program();
|
||||
|
@ -145,6 +147,11 @@ public:
|
|||
|
||||
virtual void simpleTask();
|
||||
|
||||
void mouseDownLeft(int x, int y);
|
||||
void eventMouseMove(int x, int y, const MouseState *ms);
|
||||
|
||||
void renderProgramMsgBox();
|
||||
|
||||
private:
|
||||
|
||||
void setDisplaySettings();
|
||||
|
|
|
@ -91,6 +91,9 @@ void MenuStateAbout::render(){
|
|||
renderer.renderLabel(&labelTeammateName[i]);
|
||||
renderer.renderLabel(&labelTeammateRole[i]);
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -290,14 +290,23 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){
|
|||
void MenuStateConnectedGame::render(){
|
||||
|
||||
try {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if (!settingsReceivedFromServer) return;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
int i;
|
||||
|
||||
renderer.renderButton(&buttonDisconnect);
|
||||
//renderer.renderButton(&buttonPlayNow);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
for(i=0; i<GameConstants::maxPlayers; ++i){
|
||||
renderer.renderLabel(&labelPlayers[i]);
|
||||
renderer.renderListBox(&listBoxControls[i]);
|
||||
|
@ -316,6 +325,8 @@ void MenuStateConnectedGame::render(){
|
|||
}
|
||||
}
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
renderer.renderLabel(&labelStatus);
|
||||
renderer.renderLabel(&labelInfo);
|
||||
renderer.renderLabel(&labelMap);
|
||||
|
@ -332,6 +343,8 @@ void MenuStateConnectedGame::render(){
|
|||
renderer.renderListBox(&listBoxTileset);
|
||||
renderer.renderListBox(&listBoxTechTree);
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
|
||||
renderer.renderChatManager(&chatManager);
|
||||
renderer.renderConsole(&console,showFullConsole,true);
|
||||
}
|
||||
|
@ -348,8 +361,7 @@ void MenuStateConnectedGame::update()
|
|||
Lang &lang= Lang::getInstance();
|
||||
|
||||
//update status label
|
||||
if(clientInterface->isConnected())
|
||||
{
|
||||
if(clientInterface != NULL && clientInterface->isConnected()) {
|
||||
buttonDisconnect.setText(lang.get("Disconnect"));
|
||||
|
||||
if(clientInterface->getAllowDownloadDataSynch() == false)
|
||||
|
@ -439,12 +451,14 @@ void MenuStateConnectedGame::update()
|
|||
labelStatus.setText(szBuf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(clientInterface->getSocket() != NULL)
|
||||
{
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(clientInterface != NULL && clientInterface->isConnected() == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
clientInterface->close();
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
returnToJoinMenu();
|
||||
return;
|
||||
}
|
||||
|
@ -535,41 +549,43 @@ void MenuStateConnectedGame::update()
|
|||
//update lobby
|
||||
clientInterface->updateLobby();
|
||||
|
||||
//call the chat manager
|
||||
chatManager.updateNetwork();
|
||||
clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
if(clientInterface != NULL && clientInterface->isConnected()) {
|
||||
//call the chat manager
|
||||
chatManager.updateNetwork();
|
||||
|
||||
//console
|
||||
console.update();
|
||||
//console
|
||||
console.update();
|
||||
|
||||
//intro
|
||||
if(clientInterface->getIntroDone())
|
||||
{
|
||||
labelInfo.setText(lang.get("WaitingHost"));
|
||||
//servers.setString(clientInterface->getServerName(), Ip(labelServerIp.getText()).getString());
|
||||
//intro
|
||||
if(clientInterface->getIntroDone())
|
||||
{
|
||||
labelInfo.setText(lang.get("WaitingHost"));
|
||||
//servers.setString(clientInterface->getServerName(), Ip(labelServerIp.getText()).getString());
|
||||
}
|
||||
|
||||
//launch
|
||||
if(clientInterface->getLaunchGame())
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//servers.save(serversSavedFile);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
assert(clientInterface != NULL);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
program->setState(new Game(program, clientInterface->getGameSettings()));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
//launch
|
||||
if(clientInterface->getLaunchGame())
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//servers.save(serversSavedFile);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
assert(clientInterface != NULL);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
program->setState(new Game(program, clientInterface->getGameSettings()));
|
||||
|
||||
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__);
|
||||
}
|
||||
|
||||
if(clientInterface->getLaunchGame()) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - D\n",__FILE__,__FUNCTION__);
|
||||
if(clientInterface != NULL && clientInterface->getLaunchGame()) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - D\n",__FILE__,__FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -717,6 +717,8 @@ void MenuStateCustomGame::render(){
|
|||
renderer.renderListBox(&listBoxNetworkFramePeriod);
|
||||
}
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[1024]="";
|
||||
|
|
|
@ -305,6 +305,8 @@ void MenuStateJoinGame::render(){
|
|||
|
||||
renderer.renderChatManager(&chatManager);
|
||||
renderer.renderConsole(&console);
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
}
|
||||
|
||||
void MenuStateJoinGame::update()
|
||||
|
@ -402,35 +404,37 @@ void MenuStateJoinGame::update()
|
|||
//update lobby
|
||||
clientInterface->updateLobby();
|
||||
|
||||
//call the chat manager
|
||||
chatManager.updateNetwork();
|
||||
clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
if(clientInterface != NULL && clientInterface->isConnected()) {
|
||||
//call the chat manager
|
||||
chatManager.updateNetwork();
|
||||
|
||||
//console
|
||||
console.update();
|
||||
//console
|
||||
console.update();
|
||||
|
||||
//intro
|
||||
if(clientInterface->getIntroDone())
|
||||
{
|
||||
labelInfo.setText(lang.get("WaitingHost"));
|
||||
servers.setString(clientInterface->getServerName(), Ip(labelServerIp.getText()).getString());
|
||||
//intro
|
||||
if(clientInterface->getIntroDone())
|
||||
{
|
||||
labelInfo.setText(lang.get("WaitingHost"));
|
||||
servers.setString(clientInterface->getServerName(), Ip(labelServerIp.getText()).getString());
|
||||
}
|
||||
|
||||
//launch
|
||||
if(clientInterface->getLaunchGame())
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - A\n",__FILE__,__FUNCTION__);
|
||||
|
||||
servers.save(serversSavedFile);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - B\n",__FILE__,__FUNCTION__);
|
||||
|
||||
abortAutoFind = true;
|
||||
clientInterface->stopServerDiscovery();
|
||||
program->setState(new Game(program, clientInterface->getGameSettings()));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - C\n",__FILE__,__FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
//launch
|
||||
if(clientInterface->getLaunchGame())
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - A\n",__FILE__,__FUNCTION__);
|
||||
|
||||
servers.save(serversSavedFile);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - B\n",__FILE__,__FUNCTION__);
|
||||
|
||||
abortAutoFind = true;
|
||||
clientInterface->stopServerDiscovery();
|
||||
program->setState(new Game(program, clientInterface->getGameSettings()));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - C\n",__FILE__,__FUNCTION__);
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else if(autoConnectToServer == true) {
|
||||
|
@ -438,7 +442,7 @@ void MenuStateJoinGame::update()
|
|||
connectToServer();
|
||||
}
|
||||
|
||||
if(clientInterface->getLaunchGame()) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - D\n",__FILE__,__FUNCTION__);
|
||||
if(clientInterface != NULL && clientInterface->getLaunchGame()) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - D\n",__FILE__,__FUNCTION__);
|
||||
}
|
||||
|
||||
void MenuStateJoinGame::keyDown(char key){
|
||||
|
|
|
@ -356,7 +356,8 @@ void MenuStateMasterserver::render(){
|
|||
for(int i=0; i<serverLines.size(); ++i){
|
||||
serverLines[i]->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
}
|
||||
|
||||
void MenuStateMasterserver::update(){
|
||||
|
|
|
@ -87,6 +87,8 @@ void MenuStateNewGame::render(){
|
|||
renderer.renderButton(&buttonScenario);
|
||||
renderer.renderButton(&buttonTutorial);
|
||||
renderer.renderButton(&buttonReturn);
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
}
|
||||
|
||||
void MenuStateNewGame::update(){
|
||||
|
|
|
@ -425,6 +425,8 @@ void MenuStateOptions::render(){
|
|||
renderer.renderLabel(&labelFullscreenWindowed);
|
||||
renderer.renderListBox(&listBoxFullscreenWindowed);
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
}
|
||||
|
||||
void MenuStateOptions::saveConfig(){
|
||||
|
|
|
@ -149,7 +149,7 @@ void MenuStateRoot::render(){
|
|||
if(mainMessageBox.getEnabled()){
|
||||
renderer.renderMessageBox(&mainMessageBox);
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
}
|
||||
|
||||
void MenuStateRoot::update(){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Martiño Figueroa
|
||||
// Copyright (C) 2001-2005 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -108,6 +108,8 @@ void MenuStateScenario::render(){
|
|||
|
||||
renderer.renderButton(&buttonReturn);
|
||||
renderer.renderButton(&buttonPlayNow);
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
}
|
||||
|
||||
void MenuStateScenario::update(){
|
||||
|
|
|
@ -158,7 +158,6 @@ void ClientInterface::updateLobby()
|
|||
clearChatInfo();
|
||||
|
||||
NetworkMessageType networkMessageType = getNextMessageType(true);
|
||||
|
||||
switch(networkMessageType)
|
||||
{
|
||||
case nmtInvalid:
|
||||
|
@ -171,10 +170,12 @@ void ClientInterface::updateLobby()
|
|||
if(receiveMessage(&networkMessageIntro)) {
|
||||
gotIntro = true;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got NetworkMessageIntro, networkMessageIntro.getGameState() = %d\n",__FILE__,__FUNCTION__,networkMessageIntro.getGameState());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageIntro, networkMessageIntro.getGameState() = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageIntro.getGameState());
|
||||
|
||||
//check consistency
|
||||
if(networkMessageIntro.getVersionString() != getNetworkVersionString()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
bool versionMatched = false;
|
||||
string platformFreeVersion = getNetworkPlatformFreeVersionString();
|
||||
string sErr = "";
|
||||
|
@ -213,7 +214,11 @@ void ClientInterface::updateLobby()
|
|||
}
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(networkMessageIntro.getGameState() == nmgstOk) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//send intro message
|
||||
NetworkMessageIntro sendNetworkMessageIntro(getNetworkVersionString(), Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()), -1, nmgstOk);
|
||||
|
||||
|
@ -221,14 +226,32 @@ void ClientInterface::updateLobby()
|
|||
serverName= networkMessageIntro.getName();
|
||||
sendMessage(&sendNetworkMessageIntro);
|
||||
|
||||
assert(playerIndex>=0 && playerIndex<GameConstants::maxPlayers);
|
||||
introDone= true;
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(clientSocket == NULL || clientSocket->isConnected() == false) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
string sErr = "Disconnected from server during intro handshake.";
|
||||
DisplayErrorMessage(sErr);
|
||||
quit= true;
|
||||
close();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
assert(playerIndex>=0 && playerIndex<GameConstants::maxPlayers);
|
||||
introDone= true;
|
||||
}
|
||||
}
|
||||
else if(networkMessageIntro.getGameState() == nmgstNoSlots) {
|
||||
string sErr = "Cannot join the server because there are no open slots for new players.";
|
||||
DisplayErrorMessage(sErr);
|
||||
quit= true;
|
||||
close();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -236,6 +259,7 @@ void ClientInterface::updateLobby()
|
|||
DisplayErrorMessage(sErr);
|
||||
quit= true;
|
||||
close();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -454,7 +478,8 @@ void ClientInterface::updateLobby()
|
|||
}
|
||||
}
|
||||
|
||||
if(gotIntro == false && difftime(time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) {
|
||||
if( clientSocket != NULL && clientSocket->isConnected() == true &&
|
||||
gotIntro == false && difftime(time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] difftime(time(NULL),connectedTime) = %f\n",__FILE__,__FUNCTION__,__LINE__,difftime(time(NULL),connectedTime));
|
||||
close();
|
||||
}
|
||||
|
@ -795,13 +820,15 @@ void ClientInterface::quitGame(bool userManuallyQuit)
|
|||
|
||||
void ClientInterface::close()
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] START, clientSocket = %p\n",__FILE__,__FUNCTION__,__LINE__,clientSocket);
|
||||
|
||||
delete clientSocket;
|
||||
clientSocket= NULL;
|
||||
|
||||
connectedTime = 0;
|
||||
gotIntro = false;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] END\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void ClientInterface::discoverServers(DiscoveredServersInterface *cb) {
|
||||
|
@ -892,6 +919,14 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
|||
this->receiveMessage(&msg);
|
||||
}
|
||||
break;
|
||||
case nmtBroadCastSetup:
|
||||
{
|
||||
discard = true;
|
||||
NetworkMessageLaunch msg = NetworkMessageLaunch();
|
||||
this->receiveMessage(&msg);
|
||||
}
|
||||
break;
|
||||
|
||||
case nmtPlayerIndexMessage:
|
||||
{
|
||||
discard = true;
|
||||
|
|
|
@ -1073,9 +1073,11 @@ void ServerInterface::broadcastMessage(const NetworkMessage* networkMessage, int
|
|||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
//throw runtime_error(ex.what());
|
||||
DisplayErrorMessage(ex.what());
|
||||
|
||||
//DisplayErrorMessage(ex.what());
|
||||
string sMsg = ex.what();
|
||||
sendTextMessage(sMsg,-1, true);
|
||||
}
|
||||
//serverSynchAccessor.v();
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
|
|
@ -937,8 +937,14 @@ int Socket::getDataToRead(){
|
|||
int Socket::send(const void *data, int dataSize) {
|
||||
ssize_t bytesSent= 0;
|
||||
if(isSocketValid() == true) {
|
||||
errno = 0;
|
||||
bytesSent = ::send(sock, reinterpret_cast<const char*>(data), dataSize, 0);
|
||||
}
|
||||
|
||||
// TEST errors
|
||||
//bytesSent = -1;
|
||||
// END TEST
|
||||
|
||||
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText().c_str());
|
||||
//throwException(szBuf);
|
||||
|
@ -946,16 +952,25 @@ int Socket::send(const void *data, int dataSize) {
|
|||
else if(bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during send, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
int attemptCount = 0;
|
||||
time_t tStartTimer = time(NULL);
|
||||
while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && (difftime(time(NULL),tStartTimer) <= 5)) {
|
||||
attemptCount++;
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
|
||||
|
||||
if(Socket::isWritable(true) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data);
|
||||
|
||||
bytesSent = ::send(sock, reinterpret_cast<const char*>(data), dataSize, 0);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] #2 EAGAIN during send, trying again returned: %d\n",__FILE__,__FUNCTION__,bytesSent);
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
|
||||
}
|
||||
}
|
||||
if(bytesSent <= 0) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText().c_str());
|
||||
|
||||
int iErr = getLastSocketError();
|
||||
disconnectSocket();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user