Changeset 7739
- Timestamp:
- Dec 8, 2010, 4:25:52 PM (14 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 8 edited
- 13 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/data/gui/scripts/MultiplayerMenu.lua
r7732 r7739 42 42 function P.LanButton_clicked(e) 43 43 P.joinMode = 1 44 P.showServerList() 44 45 end 45 46 46 47 function P.InternetButton_clicked(e) 47 48 P.joinMode = 2 49 P.showServerList() 48 50 end 49 51 … … 55 57 function P.MultiplayerJoinButton_clicked(e) 56 58 local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem() 57 58 if P.joinMode == 2 then 59 if choice then 60 local client = orxonox.Client:getInstance() 61 local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID() 62 client:setDestination( P.serverList[index][2], 55556 ) 63 else 64 return 65 end 66 orxonox.execute("startClient") 67 hideAllMenuSheets() 59 if choice then 60 local client = orxonox.Client:getInstance() 61 local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID() 62 client:setDestination( P.serverList[index][2], 55556 ) 68 63 else 69 --wait for Sandro's function64 return 70 65 end 71 66 orxonox.execute("startClient") 67 hideAllMenuSheets() 72 68 end 73 69 … … 77 73 78 74 function P.showServerList() 79 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 80 CEGUI.toListbox(listbox):resetList() 81 local discovery = orxonox.LANDiscovery:getInstance() 82 discovery:discover() 83 P.serverList = {} 84 local index = 0 85 local servername = "" 86 local serverip = "" 87 while true do 88 servername = discovery:getServerListItemName(index) 89 if servername == "" then 90 break 91 end 92 serverip = discovery:getServerListItemIP(index) 93 if serverip == "" then 94 break 95 end 96 table.insert(P.serverList, {servername, serverip}) 97 index = index + 1 98 end 99 index = 1 100 for k,v in pairs(P.serverList) do 101 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] ) 102 item:setID(index) 103 index = index + 1 104 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 105 CEGUI.toListbox(listbox):addItem(item) 106 end 75 -- LAN Discovery 76 if P.joinMode == 1 then 77 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 78 CEGUI.toListbox(listbox):resetList() 79 local discovery = orxonox.LANDiscovery:getInstance() 80 discovery:discover() 81 P.serverList = {} 82 local index = 0 83 local servername = "" 84 local serverip = "" 85 while true do 86 servername = discovery:getServerListItemName(index) 87 if servername == "" then 88 break 89 end 90 serverip = discovery:getServerListItemIP(index) 91 if serverip == "" then 92 break 93 end 94 table.insert(P.serverList, {servername, serverip}) 95 index = index + 1 96 end 97 index = 1 98 for k,v in pairs(P.serverList) do 99 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] ) 100 item:setID(index) 101 index = index + 1 102 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 103 CEGUI.toListbox(listbox):addItem(item) 104 end 105 -- WAN Discovery 106 elseif P.joinMode == 2 then 107 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 108 CEGUI.toListbox(listbox):resetList() 109 local discovery = orxonox.WANDiscovery:getInstance() 110 cout(0, "discovering.\n" ) 111 discovery:discover() 112 cout(0, "discovered.\n" ) 113 P.serverList = {} 114 local index = 0 115 local servername = "" 116 local serverip = "" 117 while true do 118 servername = discovery:getServerListItemName(index) 119 if servername == "" then 120 break 121 end 122 serverip = discovery:getServerListItemIP(index) 123 if serverip == "" then 124 break 125 end 126 table.insert(P.serverList, {servername, serverip}) 127 index = index + 1 128 end 129 index = 1 130 for k,v in pairs(P.serverList) do 131 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] ) 132 item:setID(index) 133 index = index + 1 134 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 135 CEGUI.toListbox(listbox):addItem(item) 136 end 137 end 138 107 139 end 108 140 -
code/branches/presentation/src/libraries/network/CMakeLists.txt
r7490 r7739 32 32 LANDiscoverable.cc 33 33 LANDiscovery.cc 34 WANDiscovery.cc 35 MasterServerComm.cc 34 36 NetworkFunction.cc 35 37 Host.cc 36 38 Server.cc 39 MasterServer.cc 40 PeerList.cc 41 ServerList.cc 37 42 ServerConnection.cc 38 43 TrafficControl.cc … … 54 59 LANDiscoverable.h 55 60 LANDiscovery.h 61 WANDiscovery.h 62 MasterServerComm.h 56 63 NetworkFunction.h 57 64 NetworkPrecompiledHeaders.h 58 65 NetworkPrereqs.h 59 66 Server.h 67 MasterServer.h 68 PeerList.h 69 ServerList.h 60 70 ServerConnection.h 61 71 TrafficControl.h … … 69 79 Client.h 70 80 LANDiscovery.h 81 WANDiscovery.h 71 82 PCH_FILE 72 83 NetworkPrecompiledHeaders.h -
code/branches/presentation/src/libraries/network/Server.cc
r7284 r7739 99 99 } 100 100 101 102 /* TODO */ 103 void Server::helper_ConnectToMasterserver() 104 { 105 /* initialize it and see if it worked */ 106 if( msc.initialize() ) 107 { COUT(1) << "Error: could not initialize master server communications!\n"; 108 return; 109 } 110 111 /* connect and see if it worked */ 112 if( msc.connect( MS_ADDRESS, 1234 ) ) 113 { COUT(1) << "Error: could not connect to master server!\n"; 114 return; 115 } 116 117 /* now send the master server some note we're here */ 118 msc.sendRequest( MSPROTO_GAME_SERVER " " MSPROTO_REGISTER_SERVER ); 119 } 120 101 121 /** 102 122 * This function opens the server by creating the listener thread … … 107 127 COUT(4) << "opening server" << endl; 108 128 this->openListener(); 129 130 /* make discoverable on LAN */ 109 131 LANDiscoverable::setActivity(true); 132 133 /* make discoverable on WAN */ 134 helper_ConnectToMasterserver(); 135 136 /* done */ 110 137 return; 111 138 } … … 140 167 141 168 169 /* TODO */ 170 int rephandler( char *addr, ENetEvent *ev ) 171 { 172 /* handle incoming data */ 173 174 /* done handling, return all ok code 0 */ 175 return 0; 176 } 177 178 void Server::helper_HandleMasterServerRequests() 179 { 180 this->msc.pollForReply( rephandler ); 181 } 182 142 183 /** 143 184 * Run this function once every tick … … 149 190 // receive incoming packets 150 191 Connection::processQueue(); 192 151 193 // receive and process incoming discovery packets 152 194 LANDiscoverable::update(); 195 196 // receive and process requests from master server 197 helper_HandleMasterServerRequests(); 153 198 154 199 if ( ClientInformation::hasClients() ) -
code/branches/presentation/src/libraries/network/Server.h
r7163 r7739 38 38 #include "ServerConnection.h" 39 39 #include "LANDiscoverable.h" 40 #include "MasterServerComm.h" 41 #include "MasterServerProtocol.h" 42 40 43 41 44 namespace orxonox … … 52 55 Server(int port, const std::string& bindAddress); 53 56 ~Server(); 57 58 /* helpers */ 59 void helper_ConnectToMasterserver(); 60 void helper_HandleMasterServerRequests(); 61 int replyhandler( char *addr, ENetEvent *ev ); 54 62 55 63 void open(); … … 82 90 83 91 float timeSinceLastUpdate_; 92 MasterServerComm msc; 84 93 }; 85 94 -
code/branches/presentation/src/libraries/network/WANDiscovery.cc
r7737 r7739 41 41 ManageScopedSingleton(WANDiscovery, ScopeID::Root, true); 42 42 43 void WANDiscovery::setConfigValues()44 {45 SetConfigValue(this->msaddr, "msaddr");46 }47 43 48 44 WANDiscovery::WANDiscovery() … … 54 50 RegisterObject(WANDiscovery); 55 51 56 /* set default string for this->msaddr */57 this->msaddr = "localhost";58 59 52 /* ... and register a config value function for it */ 60 53 this->setConfigValues(); … … 65 58 66 59 /* connect and see if it worked */ 67 if( msc.connect( this->msaddr .c_str(), 1234 ) )60 if( msc.connect( this->msaddress.c_str(), 1234 ) ) 68 61 COUT(2) << "Error: could not connect to master server at " 69 << this->msaddr << std::endl;62 << this->msaddress << std::endl; 70 63 71 64 /* debugging output */ 72 65 COUT(4) << "Initialization of WANDiscovery complete.\n"; 73 66 } 67 68 void WANDiscovery::setConfigValues() 69 { 70 SetConfigValue( msaddress, "localhost"); 71 } 74 72 75 73 WANDiscovery::~WANDiscovery() -
code/branches/presentation/src/libraries/network/WANDiscovery.h
r7737 r7739 100 100 101 101 /** master server address */ 102 std::string msaddr ;102 std::string msaddress; 103 103 104 104 }; // tolua_export -
code/branches/presentation/src/libraries/network/packet/ServerInformation.h
r7459 r7739 50 50 std::string getServerName() { return this->serverName_; } 51 51 void setServerName(std::string name) { this->serverName_ = name; } 52 void setServerIP( std::string IP ) { this->serverIP_ = IP; } 52 53 uint32_t getServerRTT() { return this->serverRTT_; } 53 54 -
code/branches/presentation/src/orxonox/Main.cc
r7431 r7739 54 54 SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode"); 55 55 56 /* ADD masterserver command */ 57 SetCommandLineSwitch(masterserver).information("Start in masterserver mode"); 58 56 59 SetCommandLineArgument(generateDoc, "") 57 60 .information("Generates a Doxygen file from things like SetConsoleCommand"); … … 67 70 if (CommandLineParser::getValue("generateDoc").getString().empty()) 68 71 { 72 /* TODO make this clear */ 69 73 game->setStateHierarchy( 70 74 "root" … … 90 94 else if (CommandLineParser::getValue("dedicatedClient").getBool()) 91 95 Game::getInstance().requestStates("client, level"); 96 /* ADD masterserver command */ 97 else if (CommandLineParser::getValue("masterserver").getBool()) 98 Game::getInstance().requestStates("masterserver"); 92 99 else 93 100 { -
code/branches/presentation/src/orxonox/gamestates/CMakeLists.txt
r6105 r7739 6 6 GSRoot.cc 7 7 GSServer.cc 8 GSMasterServer.cc 8 9 GSStandalone.cc 9 10 )
Note: See TracChangeset
for help on using the changeset viewer.