diff --git a/mk/linux/configuration.xml b/mk/linux/configuration.xml index 780f8b63..25176759 100644 --- a/mk/linux/configuration.xml +++ b/mk/linux/configuration.xml @@ -342,6 +342,12 @@ when they are issued a command"/> + + + + + + diff --git a/source/glest_game/game/chat_manager.cpp b/source/glest_game/game/chat_manager.cpp index 7a3494db..e99e9c8f 100644 --- a/source/glest_game/game/chat_manager.cpp +++ b/source/glest_game/game/chat_manager.cpp @@ -63,9 +63,9 @@ void ChatManager::keyDown(char key){ GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); editEnabled= false; - if(!text.empty()){ - console->addLine(Config::getInstance().getString("NetPlayerName") + ": " + text); - gameNetworkInterface->sendTextMessage(Config::getInstance().getString("NetPlayerName")+": "+ + if(!text.empty()) { + console->addLine(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": " + text); + gameNetworkInterface->sendTextMessage(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": "+ text, teamMode? thisTeamIndex: -1); } } diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 9155257c..ec8dfb4f 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -3,9 +3,9 @@ // // Copyright (C) 2001-2005 Marti�o 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 +// 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 // ============================================================== @@ -28,7 +28,7 @@ namespace Glest{ namespace Game{ // class MenuStateOptions // ===================================================== -MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): +MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): MenuState(program, mainMenu, "config") { Lang &lang= Lang::getInstance(); @@ -36,8 +36,8 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): activeInputLabel=NULL; //create - buttonOk.init(200, 150, 100); - buttonAbort.init(310, 150, 100); + buttonOk.init(200, 150, 100); + buttonAbort.init(310, 150, 100); buttonAutoConfig.init(450, 150, 125); //labels @@ -48,7 +48,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): labelLang.init(200, 400); labelPlayerNameLabel.init(200,370); labelPlayerName.init(350,370); - + labelFilter.init(200, 340); labelShadows.init(200, 310); labelTextures3D.init(200, 280); @@ -62,13 +62,13 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): listBoxMusicSelect.init(350, 440, 150); listBoxLang.init(350, 400, 170); - + listBoxFilter.init(350, 340, 170); listBoxShadows.init(350, 310, 170); listBoxTextures3D.init(350, 280, 80); listBoxLights.init(350, 250, 80); listBoxUnitParticles.init(350,220,80); - + //set text buttonOk.setText(lang.get("Ok")); buttonAbort.setText(lang.get("Abort")); @@ -94,10 +94,10 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): } listBoxLang.setItems(langResults); listBoxLang.setSelectedItem(config.getString("Lang")); - + //playerName - labelPlayerName.setText(config.getString("NetPlayerName")); - + labelPlayerName.setText(config.getString("NetPlayerName",Socket::getHostName().c_str())); + //shadows for(int i= 0; i(i)))); @@ -115,7 +115,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): listBoxTextures3D.pushBackItem(lang.get("No")); listBoxTextures3D.pushBackItem(lang.get("Yes")); listBoxTextures3D.setSelectedItemIndex(clamp(config.getInt("Textures3D"), 0, 1)); - + //textures 3d listBoxUnitParticles.pushBackItem(lang.get("No")); listBoxUnitParticles.pushBackItem(lang.get("Yes")); @@ -136,7 +136,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5)); listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5)); listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5)); - + } 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()); saveConfig(); mainMenu->setState(new MenuStateRoot(program, mainMenu)); - } + } else if(buttonAbort.mouseClick(x, y)){ soundRenderer.playFx(coreData.getClickSoundA()); mainMenu->setState(new MenuStateRoot(program, mainMenu)); - } + } else if(buttonAutoConfig.mouseClick(x, y)){ soundRenderer.playFx(coreData.getClickSoundA()); Renderer::getInstance().autoConfig(); saveConfig(); mainMenu->setState(new MenuStateOptions(program, mainMenu)); - } + } else if(labelPlayerName.mouseClick(x, y) && ( activeInputLabel != &labelPlayerName )){ setActiveInputLable(&labelPlayerName); } @@ -215,11 +215,11 @@ void MenuStateOptions::keyPress(char c){ (c=='-')||(c=='(')||(c==')')){ if(activeInputLabel->getText().size()getText(); - text.insert(text.end()-1, c); + text.insert(text.end()-1, c); activeInputLabel->setText(text); } } - } + } } } @@ -255,7 +255,7 @@ void MenuStateOptions::saveConfig(){ Config &config= Config::getInstance(); Lang &lang= Lang::getInstance(); setActiveInputLable(NULL); - + if(labelPlayerName.getText().length()>0) { config.setString("NetPlayerName", labelPlayerName.getText()); diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index 53d8659a..fd72d014 100755 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -160,7 +160,7 @@ void ClientInterface::updateLobby() //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(); serverName= networkMessageIntro.getName(); diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index e8af2240..088243d7 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -349,7 +349,7 @@ void ServerInterface::waitUntilReady(Checksum* checksum){ } 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); } diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index 90cb8e49..f3373488 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -77,8 +77,8 @@ public: bool isWritable(bool waitOnDelayedResponse); bool isConnected(); - string getHostName() const; - string getIp() const; + static string getHostName(); + static string getIp(); protected: static void throwException(const string &str); diff --git a/source/shared_lib/include/platform/win32/socket.h b/source/shared_lib/include/platform/win32/socket.h index 0743cfb2..dfd885b0 100644 --- a/source/shared_lib/include/platform/win32/socket.h +++ b/source/shared_lib/include/platform/win32/socket.h @@ -81,8 +81,8 @@ public: bool isWritable(bool waitOnDelayedResponse); bool isConnected(); - string getHostName() const; - string getIp() const; + static string getHostName(); + static string getIp(); protected: static void throwException(const string &str); diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 191ad137..2d765c7d 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -514,14 +514,14 @@ bool Socket::isConnected() return true; } -string Socket::getHostName() const { +string Socket::getHostName() { const int strSize= 256; char hostname[strSize]; gethostname(hostname, strSize); return hostname; } -string Socket::getIp() const{ +string Socket::getIp() { hostent* info= gethostbyname(getHostName().c_str()); unsigned char* address; diff --git a/source/shared_lib/sources/platform/win32/socket.cpp b/source/shared_lib/sources/platform/win32/socket.cpp index 623f2957..06c5cccf 100644 --- a/source/shared_lib/sources/platform/win32/socket.cpp +++ b/source/shared_lib/sources/platform/win32/socket.cpp @@ -625,14 +625,14 @@ bool Socket::isConnected(){ return true; } -string Socket::getHostName() const{ +string Socket::getHostName() { const int strSize= 256; char hostname[strSize]; gethostname(hostname, strSize); return hostname; } -string Socket::getIp() const{ +string Socket::getIp() { hostent* info= gethostbyname(getHostName().c_str()); unsigned char* address;