mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 20:22:31 +01:00
- fixing crash on client connect screen
This commit is contained in:
parent
ac31d06106
commit
1a2f0175a8
@ -24,10 +24,18 @@
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
//misc consts
|
||||
struct MapInfo{
|
||||
class MapInfo {
|
||||
public:
|
||||
|
||||
Vec2i size;
|
||||
int players;
|
||||
string desc;
|
||||
|
||||
MapInfo() {
|
||||
size = Vec2i(0,0);
|
||||
players = 0;
|
||||
desc = "";
|
||||
}
|
||||
};
|
||||
|
||||
struct ScenarioInfo
|
||||
|
@ -50,11 +50,6 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||
{
|
||||
lastNetworkSendPing = 0;
|
||||
pingCount = 0;
|
||||
|
||||
returnMenuInfo=joinMenuInfo;
|
||||
Lang &lang= Lang::getInstance();
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
Config &config = Config::getInstance();
|
||||
needToSetChangedGameSettings = false;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
showFullConsole=false;
|
||||
@ -62,7 +57,14 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||
currentFactionName="";
|
||||
currentMap="";
|
||||
settingsReceivedFromServer=false;
|
||||
initialSettingsReceivedFromServer=false;
|
||||
|
||||
returnMenuInfo=joinMenuInfo;
|
||||
Lang &lang= Lang::getInstance();
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
Config &config = Config::getInstance();
|
||||
|
||||
labelMapInfo.setText("?");
|
||||
|
||||
vector<string> teamItems, controlItems, results;
|
||||
//state
|
||||
@ -225,7 +227,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||
labelFaction.setText(lang.get("Faction"));
|
||||
labelTeam.setText(lang.get("Team"));
|
||||
|
||||
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__);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
|
||||
//init controllers
|
||||
@ -240,8 +242,6 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||
|
||||
//if (!settingsReceivedFromServer) return;
|
||||
|
||||
if(buttonDisconnect.mouseClick(x,y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
@ -261,9 +261,13 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
currentFactionName="";
|
||||
currentMap="";
|
||||
returnToJoinMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!initialSettingsReceivedFromServer) return;
|
||||
|
||||
// Only allow changes after we get game settings from the server
|
||||
else if( clientInterface->isConnected() == true &&
|
||||
if( clientInterface->isConnected() == true &&
|
||||
clientInterface->getGameSettingsReceived() == true) {
|
||||
if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@ -358,7 +362,7 @@ void MenuStateConnectedGame::render(){
|
||||
try {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if (!settingsReceivedFromServer) return;
|
||||
if (!initialSettingsReceivedFromServer) return;
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
@ -672,6 +676,7 @@ void MenuStateConnectedGame::update()
|
||||
}
|
||||
|
||||
settingsReceivedFromServer=true;
|
||||
initialSettingsReceivedFromServer=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ private:
|
||||
bool settingsReceivedFromServer;
|
||||
time_t lastNetworkSendPing;
|
||||
int pingCount;
|
||||
bool initialSettingsReceivedFromServer;
|
||||
|
||||
|
||||
public:
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2007 Martiño Figueroa
|
||||
// Copyright (C) 2001-2007 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
@ -10,11 +10,18 @@
|
||||
// ==============================================================
|
||||
|
||||
#include "font.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include "conversion.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Shared::Util;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
int Font::charCount= 256;
|
||||
std::string Font::fontTypeName = "Times New Roman";
|
||||
|
||||
// =====================================================
|
||||
// class FontMetrics
|
||||
// =====================================================
|
||||
@ -30,11 +37,16 @@ FontMetrics::FontMetrics(){
|
||||
|
||||
FontMetrics::~FontMetrics(){
|
||||
delete [] widths;
|
||||
widths = NULL;
|
||||
}
|
||||
|
||||
float FontMetrics::getTextWidth(const string &str) const{
|
||||
float width= 0.f;
|
||||
for(unsigned int i=0; i<str.size(); ++i){
|
||||
for(unsigned int i=0; i< str.size() && i < Font::charCount; ++i){
|
||||
if(str[i] >= Font::charCount) {
|
||||
string sError = "str[i] >= Font::charCount, [" + str + "] i = " + intToStr(i);
|
||||
throw runtime_error(sError);
|
||||
}
|
||||
width+= widths[str[i]];
|
||||
}
|
||||
return width;
|
||||
@ -48,9 +60,6 @@ float FontMetrics::getHeight() const{
|
||||
// class Font
|
||||
// ===============================================
|
||||
|
||||
int Font::charCount= 256;
|
||||
std::string Font::fontTypeName = "Times New Roman";
|
||||
|
||||
Font::Font(){
|
||||
inited= false;
|
||||
type= fontTypeName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user