[Orxonox-commit 2996] r7692 - in code/branches/masterserver: data/gui/scripts src/libraries/network src/modules/masterserver
smerkli at orxonox.net
smerkli at orxonox.net
Wed Dec 1 16:28:46 CET 2010
Author: smerkli
Date: 2010-12-01 16:28:46 +0100 (Wed, 01 Dec 2010)
New Revision: 7692
Modified:
code/branches/masterserver/data/gui/scripts/MultiplayerMenu.lua
code/branches/masterserver/src/libraries/network/MasterServerComm.cc
code/branches/masterserver/src/libraries/network/MasterServerProtocol.h
code/branches/masterserver/src/libraries/network/WANDiscovery.cc
code/branches/masterserver/src/libraries/network/WANDiscovery.h
code/branches/masterserver/src/modules/masterserver/MasterServer.cc
Log:
done for today, didn't get bug to leave, and connect doesn't quite work yet.
Modified: code/branches/masterserver/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- code/branches/masterserver/data/gui/scripts/MultiplayerMenu.lua 2010-12-01 15:28:06 UTC (rev 7691)
+++ code/branches/masterserver/data/gui/scripts/MultiplayerMenu.lua 2010-12-01 15:28:46 UTC (rev 7692)
@@ -97,7 +97,7 @@
end
end
-function P.showServerList()
+function P.showServerListmeow()
local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
CEGUI.toListbox(listbox):resetList()
local discovery = orxonox.LANDiscovery:getInstance()
@@ -130,11 +130,13 @@
-- same as above, but use WAN Discovery
-function P.showServerListWAN()
+function P.showServerList()
local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
CEGUI.toListbox(listbox):resetList()
local discovery = orxonox.WANDiscovery:getInstance()
+ cout(0, "discovering.\n" )
discovery:discover()
+ cout(0, "discovered.\n" )
P.serverList = {}
local index = 0
local servername = ""
Modified: code/branches/masterserver/src/libraries/network/MasterServerComm.cc
===================================================================
--- code/branches/masterserver/src/libraries/network/MasterServerComm.cc 2010-12-01 15:28:06 UTC (rev 7691)
+++ code/branches/masterserver/src/libraries/network/MasterServerComm.cc 2010-12-01 15:28:46 UTC (rev 7692)
@@ -109,16 +109,16 @@
{
/* see whether anything happened */
/* WORK MARK REMOVE THIS OUTPUT */
- //COUT(2) << "MARK polling...\n";
+ COUT(2) << "polling masterserver...\n";
+ /* address buffer */
+ char *addrconv = NULL;
+ int retval = 0;
+
/* enet_host_service returns 0 if no event occured */
/* just newly set below test to >0 from >= 0, to be tested */
if( enet_host_service( this->client, this->event, 1000 ) > 0 )
{
- /* address buffer */
- char *addrconv = NULL;
- int retval = 0;
-
/* check what type of event it is and react accordingly */
switch (this->event->type)
{ /* new connection, not supposed to happen. */
@@ -130,6 +130,12 @@
/* incoming data */
case ENET_EVENT_TYPE_RECEIVE:
addrconv = (char *) calloc( 50, 1 );
+ if( !addrconv )
+ { COUT(2) << "MasterServerComm.cc: Could not allocate memory!\n";
+ break;
+ }
+
+ /* resolve IP */
enet_address_get_host_ip( &(this->event->peer->address),
addrconv, 49 );
@@ -174,7 +180,8 @@
/* One could just use enet_host_service() instead. */
enet_host_flush( this->client );
- if( packet ) free( packet );
+ /* free the packet */
+ enet_packet_destroy( packet );
/* all done. */
return 0;
Modified: code/branches/masterserver/src/libraries/network/MasterServerProtocol.h
===================================================================
--- code/branches/masterserver/src/libraries/network/MasterServerProtocol.h 2010-12-01 15:28:06 UTC (rev 7691)
+++ code/branches/masterserver/src/libraries/network/MasterServerProtocol.h 2010-12-01 15:28:46 UTC (rev 7692)
@@ -30,7 +30,7 @@
#define MASTER_SERVER_PROTO
/* master server address (to be moved elsewhere later) */
-#define MS_ADDRESS "172.16.113.1"
+#define MS_ADDRESS "129.132.3.8"
#define MSPROTO_CLIENT "CL"
#define MSPROTO_CLIENT_LEN 2
Modified: code/branches/masterserver/src/libraries/network/WANDiscovery.cc
===================================================================
--- code/branches/masterserver/src/libraries/network/WANDiscovery.cc 2010-12-01 15:28:06 UTC (rev 7691)
+++ code/branches/masterserver/src/libraries/network/WANDiscovery.cc 2010-12-01 15:28:46 UTC (rev 7692)
@@ -95,11 +95,11 @@
* as 1 is used to signal that we're done receiving
* the list
*/
- return 1;
+ return 2;
}
/* done handling, return all ok code 0 */
- return 0;
+ return 1;
}
void WANDiscovery::discover()
@@ -111,11 +111,19 @@
this->msc.sendRequest( MSPROTO_CLIENT " " MSPROTO_REQ_LIST );
/* poll for replies */
- /* TODO add some timeout here so we don't wait indefinitely */
- while( !((this->msc).pollForReply( rhandler )) )
- /* nothing */;
-
- /* done receiving. */
+ int i = WANDISC_MAXTRIES;
+ while( i > 0 )
+ {
+ /* poll for reply and act according to what was received */
+ switch( this->msc.pollForReply( rhandler ) )
+ { case 0: /* no event occured, decrease timeout */
+ --i; break;
+ case 1: /* got a list element, continue */
+ break;
+ case 2: /* done. */
+ i = 0; break;
+ }
+ }
}
std::string WANDiscovery::getServerListItemName(unsigned int index)
Modified: code/branches/masterserver/src/libraries/network/WANDiscovery.h
===================================================================
--- code/branches/masterserver/src/libraries/network/WANDiscovery.h 2010-12-01 15:28:06 UTC (rev 7691)
+++ code/branches/masterserver/src/libraries/network/WANDiscovery.h 2010-12-01 15:28:46 UTC (rev 7692)
@@ -37,6 +37,7 @@
#include <vector>
+#define WANDISC_MAXTRIES 5
// tolua_begin
namespace orxonox
Modified: code/branches/masterserver/src/modules/masterserver/MasterServer.cc
===================================================================
--- code/branches/masterserver/src/modules/masterserver/MasterServer.cc 2010-12-01 15:28:06 UTC (rev 7691)
+++ code/branches/masterserver/src/modules/masterserver/MasterServer.cc 2010-12-01 15:28:46 UTC (rev 7692)
@@ -34,7 +34,7 @@
namespace orxonox
{
/* singleton stuff */
- ManageScopedSingleton( MasterServer, ScopeID::Root, false );
+ //ManageScopedSingleton( MasterServer, ScopeID::Root, false );
/* helpers */
static void
More information about the Orxonox-commit
mailing list