Updates to new netplayer code to default the value to the hostname and not crash if the property is missing from glest.ini. Also added new property to configurator
This commit is contained in:
parent
5b713bd785
commit
237b76e2f2
|
@ -342,6 +342,12 @@ when they are issued a command"/>
|
||||||
<description value=""/>
|
<description value=""/>
|
||||||
<default value="6666"/>
|
<default value="6666"/>
|
||||||
</field>
|
</field>
|
||||||
|
<field type="String">
|
||||||
|
<name value="Network player name"/>
|
||||||
|
<variable-name value="NetPlayerName"/>
|
||||||
|
<description value="Your player name for network games"/>
|
||||||
|
<default value="192.168.1.1"/>
|
||||||
|
</field>
|
||||||
<field type="Enum">
|
<field type="Enum">
|
||||||
<name value="Client data consistency checks"/>
|
<name value="Client data consistency checks"/>
|
||||||
<variable-name value="NetworkConsistencyChecks"/>
|
<variable-name value="NetworkConsistencyChecks"/>
|
||||||
|
|
|
@ -63,9 +63,9 @@ void ChatManager::keyDown(char key){
|
||||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||||
|
|
||||||
editEnabled= false;
|
editEnabled= false;
|
||||||
if(!text.empty()){
|
if(!text.empty()) {
|
||||||
console->addLine(Config::getInstance().getString("NetPlayerName") + ": " + text);
|
console->addLine(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": " + text);
|
||||||
gameNetworkInterface->sendTextMessage(Config::getInstance().getString("NetPlayerName")+": "+
|
gameNetworkInterface->sendTextMessage(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": "+
|
||||||
text, teamMode? thisTeamIndex: -1);
|
text, teamMode? thisTeamIndex: -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
// by the Free Software Foundation; either version 2 of the
|
// by the Free Software Foundation; either version 2 of the
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace Glest{ namespace Game{
|
||||||
// class MenuStateOptions
|
// class MenuStateOptions
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
MenuState(program, mainMenu, "config")
|
MenuState(program, mainMenu, "config")
|
||||||
{
|
{
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
@ -36,8 +36,8 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
activeInputLabel=NULL;
|
activeInputLabel=NULL;
|
||||||
|
|
||||||
//create
|
//create
|
||||||
buttonOk.init(200, 150, 100);
|
buttonOk.init(200, 150, 100);
|
||||||
buttonAbort.init(310, 150, 100);
|
buttonAbort.init(310, 150, 100);
|
||||||
buttonAutoConfig.init(450, 150, 125);
|
buttonAutoConfig.init(450, 150, 125);
|
||||||
|
|
||||||
//labels
|
//labels
|
||||||
|
@ -48,7 +48,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
labelLang.init(200, 400);
|
labelLang.init(200, 400);
|
||||||
labelPlayerNameLabel.init(200,370);
|
labelPlayerNameLabel.init(200,370);
|
||||||
labelPlayerName.init(350,370);
|
labelPlayerName.init(350,370);
|
||||||
|
|
||||||
labelFilter.init(200, 340);
|
labelFilter.init(200, 340);
|
||||||
labelShadows.init(200, 310);
|
labelShadows.init(200, 310);
|
||||||
labelTextures3D.init(200, 280);
|
labelTextures3D.init(200, 280);
|
||||||
|
@ -62,13 +62,13 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
listBoxMusicSelect.init(350, 440, 150);
|
listBoxMusicSelect.init(350, 440, 150);
|
||||||
|
|
||||||
listBoxLang.init(350, 400, 170);
|
listBoxLang.init(350, 400, 170);
|
||||||
|
|
||||||
listBoxFilter.init(350, 340, 170);
|
listBoxFilter.init(350, 340, 170);
|
||||||
listBoxShadows.init(350, 310, 170);
|
listBoxShadows.init(350, 310, 170);
|
||||||
listBoxTextures3D.init(350, 280, 80);
|
listBoxTextures3D.init(350, 280, 80);
|
||||||
listBoxLights.init(350, 250, 80);
|
listBoxLights.init(350, 250, 80);
|
||||||
listBoxUnitParticles.init(350,220,80);
|
listBoxUnitParticles.init(350,220,80);
|
||||||
|
|
||||||
//set text
|
//set text
|
||||||
buttonOk.setText(lang.get("Ok"));
|
buttonOk.setText(lang.get("Ok"));
|
||||||
buttonAbort.setText(lang.get("Abort"));
|
buttonAbort.setText(lang.get("Abort"));
|
||||||
|
@ -94,10 +94,10 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
}
|
}
|
||||||
listBoxLang.setItems(langResults);
|
listBoxLang.setItems(langResults);
|
||||||
listBoxLang.setSelectedItem(config.getString("Lang"));
|
listBoxLang.setSelectedItem(config.getString("Lang"));
|
||||||
|
|
||||||
//playerName
|
//playerName
|
||||||
labelPlayerName.setText(config.getString("NetPlayerName"));
|
labelPlayerName.setText(config.getString("NetPlayerName",Socket::getHostName().c_str()));
|
||||||
|
|
||||||
//shadows
|
//shadows
|
||||||
for(int i= 0; i<Renderer::sCount; ++i){
|
for(int i= 0; i<Renderer::sCount; ++i){
|
||||||
listBoxShadows.pushBackItem(lang.get(Renderer::shadowsToStr(static_cast<Renderer::Shadows>(i))));
|
listBoxShadows.pushBackItem(lang.get(Renderer::shadowsToStr(static_cast<Renderer::Shadows>(i))));
|
||||||
|
@ -115,7 +115,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
listBoxTextures3D.pushBackItem(lang.get("No"));
|
listBoxTextures3D.pushBackItem(lang.get("No"));
|
||||||
listBoxTextures3D.pushBackItem(lang.get("Yes"));
|
listBoxTextures3D.pushBackItem(lang.get("Yes"));
|
||||||
listBoxTextures3D.setSelectedItemIndex(clamp(config.getInt("Textures3D"), 0, 1));
|
listBoxTextures3D.setSelectedItemIndex(clamp(config.getInt("Textures3D"), 0, 1));
|
||||||
|
|
||||||
//textures 3d
|
//textures 3d
|
||||||
listBoxUnitParticles.pushBackItem(lang.get("No"));
|
listBoxUnitParticles.pushBackItem(lang.get("No"));
|
||||||
listBoxUnitParticles.pushBackItem(lang.get("Yes"));
|
listBoxUnitParticles.pushBackItem(lang.get("Yes"));
|
||||||
|
@ -136,7 +136,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5));
|
listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5));
|
||||||
listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5));
|
listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5));
|
||||||
listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5));
|
listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
@ -149,17 +149,17 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||||
}
|
}
|
||||||
else if(buttonAbort.mouseClick(x, y)){
|
else if(buttonAbort.mouseClick(x, y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||||
}
|
}
|
||||||
else if(buttonAutoConfig.mouseClick(x, y)){
|
else if(buttonAutoConfig.mouseClick(x, y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
Renderer::getInstance().autoConfig();
|
Renderer::getInstance().autoConfig();
|
||||||
saveConfig();
|
saveConfig();
|
||||||
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
||||||
}
|
}
|
||||||
else if(labelPlayerName.mouseClick(x, y) && ( activeInputLabel != &labelPlayerName )){
|
else if(labelPlayerName.mouseClick(x, y) && ( activeInputLabel != &labelPlayerName )){
|
||||||
setActiveInputLable(&labelPlayerName);
|
setActiveInputLable(&labelPlayerName);
|
||||||
}
|
}
|
||||||
|
@ -215,11 +215,11 @@ void MenuStateOptions::keyPress(char c){
|
||||||
(c=='-')||(c=='(')||(c==')')){
|
(c=='-')||(c=='(')||(c==')')){
|
||||||
if(activeInputLabel->getText().size()<maxTextSize){
|
if(activeInputLabel->getText().size()<maxTextSize){
|
||||||
string text= activeInputLabel->getText();
|
string text= activeInputLabel->getText();
|
||||||
text.insert(text.end()-1, c);
|
text.insert(text.end()-1, c);
|
||||||
activeInputLabel->setText(text);
|
activeInputLabel->setText(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ void MenuStateOptions::saveConfig(){
|
||||||
Config &config= Config::getInstance();
|
Config &config= Config::getInstance();
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
setActiveInputLable(NULL);
|
setActiveInputLable(NULL);
|
||||||
|
|
||||||
if(labelPlayerName.getText().length()>0)
|
if(labelPlayerName.getText().length()>0)
|
||||||
{
|
{
|
||||||
config.setString("NetPlayerName", labelPlayerName.getText());
|
config.setString("NetPlayerName", labelPlayerName.getText());
|
||||||
|
|
|
@ -160,7 +160,7 @@ void ClientInterface::updateLobby()
|
||||||
|
|
||||||
|
|
||||||
//send intro message
|
//send intro message
|
||||||
NetworkMessageIntro sendNetworkMessageIntro(getNetworkVersionString(), Config::getInstance().getString("NetPlayerName"), -1);
|
NetworkMessageIntro sendNetworkMessageIntro(getNetworkVersionString(), Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()), -1);
|
||||||
|
|
||||||
playerIndex= networkMessageIntro.getPlayerIndex();
|
playerIndex= networkMessageIntro.getPlayerIndex();
|
||||||
serverName= networkMessageIntro.getName();
|
serverName= networkMessageIntro.getName();
|
||||||
|
|
|
@ -349,7 +349,7 @@ void ServerInterface::waitUntilReady(Checksum* checksum){
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerInterface::sendTextMessage(const string &text, int teamIndex){
|
void ServerInterface::sendTextMessage(const string &text, int teamIndex){
|
||||||
NetworkMessageText networkMessageText(text, Config::getInstance().getString("NetPlayerName"), teamIndex);
|
NetworkMessageText networkMessageText(text, Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()), teamIndex);
|
||||||
broadcastMessage(&networkMessageText);
|
broadcastMessage(&networkMessageText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,8 @@ public:
|
||||||
bool isWritable(bool waitOnDelayedResponse);
|
bool isWritable(bool waitOnDelayedResponse);
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
|
|
||||||
string getHostName() const;
|
static string getHostName();
|
||||||
string getIp() const;
|
static string getIp();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void throwException(const string &str);
|
static void throwException(const string &str);
|
||||||
|
|
|
@ -81,8 +81,8 @@ public:
|
||||||
bool isWritable(bool waitOnDelayedResponse);
|
bool isWritable(bool waitOnDelayedResponse);
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
|
|
||||||
string getHostName() const;
|
static string getHostName();
|
||||||
string getIp() const;
|
static string getIp();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void throwException(const string &str);
|
static void throwException(const string &str);
|
||||||
|
|
|
@ -514,14 +514,14 @@ bool Socket::isConnected()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Socket::getHostName() const {
|
string Socket::getHostName() {
|
||||||
const int strSize= 256;
|
const int strSize= 256;
|
||||||
char hostname[strSize];
|
char hostname[strSize];
|
||||||
gethostname(hostname, strSize);
|
gethostname(hostname, strSize);
|
||||||
return hostname;
|
return hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Socket::getIp() const{
|
string Socket::getIp() {
|
||||||
hostent* info= gethostbyname(getHostName().c_str());
|
hostent* info= gethostbyname(getHostName().c_str());
|
||||||
unsigned char* address;
|
unsigned char* address;
|
||||||
|
|
||||||
|
|
|
@ -625,14 +625,14 @@ bool Socket::isConnected(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Socket::getHostName() const{
|
string Socket::getHostName() {
|
||||||
const int strSize= 256;
|
const int strSize= 256;
|
||||||
char hostname[strSize];
|
char hostname[strSize];
|
||||||
gethostname(hostname, strSize);
|
gethostname(hostname, strSize);
|
||||||
return hostname;
|
return hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Socket::getIp() const{
|
string Socket::getIp() {
|
||||||
hostent* info= gethostbyname(getHostName().c_str());
|
hostent* info= gethostbyname(getHostName().c_str());
|
||||||
unsigned char* address;
|
unsigned char* address;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user