Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7739


Ignore:
Timestamp:
Dec 8, 2010, 4:25:52 PM (13 years ago)
Author:
dafrick
Message:

Merging masterserver branch to new presentation branch.

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  
    4242function P.LanButton_clicked(e)
    4343    P.joinMode = 1
     44        P.showServerList()
    4445end
    4546
    4647function P.InternetButton_clicked(e)
    4748    P.joinMode = 2
     49        P.showServerList()
    4850end
    4951
     
    5557function P.MultiplayerJoinButton_clicked(e)
    5658    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 )
    6863    else
    69         --wait for Sandro's function
     64        return
    7065    end
    71 
     66    orxonox.execute("startClient")
     67    hideAllMenuSheets()
    7268end
    7369
     
    7773
    7874function 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       
    107139end
    108140
  • code/branches/presentation/src/libraries/network/CMakeLists.txt

    r7490 r7739  
    3232  LANDiscoverable.cc
    3333  LANDiscovery.cc
     34  WANDiscovery.cc
     35  MasterServerComm.cc
    3436  NetworkFunction.cc
    3537  Host.cc
    3638  Server.cc
     39  MasterServer.cc
     40  PeerList.cc
     41  ServerList.cc
    3742  ServerConnection.cc
    3843  TrafficControl.cc
     
    5459  LANDiscoverable.h
    5560  LANDiscovery.h
     61  WANDiscovery.h
     62  MasterServerComm.h
    5663  NetworkFunction.h
    5764  NetworkPrecompiledHeaders.h
    5865  NetworkPrereqs.h
    5966  Server.h
     67  MasterServer.h
     68  PeerList.h
     69  ServerList.h
    6070  ServerConnection.h
    6171  TrafficControl.h
     
    6979    Client.h
    7080    LANDiscovery.h
     81    WANDiscovery.h
    7182  PCH_FILE
    7283    NetworkPrecompiledHeaders.h
  • code/branches/presentation/src/libraries/network/Server.cc

    r7284 r7739  
    9999  }
    100100
     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
    101121  /**
    102122  * This function opens the server by creating the listener thread
     
    107127    COUT(4) << "opening server" << endl;
    108128    this->openListener();
     129   
     130    /* make discoverable on LAN */
    109131    LANDiscoverable::setActivity(true);
     132
     133    /* make discoverable on WAN */
     134    helper_ConnectToMasterserver();
     135
     136    /* done */
    110137    return;
    111138  }
     
    140167
    141168
     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
    142183  /**
    143184  * Run this function once every tick
     
    149190    // receive incoming packets
    150191    Connection::processQueue();
     192
    151193    // receive and process incoming discovery packets
    152194    LANDiscoverable::update();
     195
     196    // receive and process requests from master server
     197    helper_HandleMasterServerRequests();
    153198
    154199    if ( ClientInformation::hasClients() )
  • code/branches/presentation/src/libraries/network/Server.h

    r7163 r7739  
    3838#include "ServerConnection.h"
    3939#include "LANDiscoverable.h"
     40#include "MasterServerComm.h"
     41#include "MasterServerProtocol.h"
     42
    4043
    4144namespace orxonox
     
    5255    Server(int port, const std::string& bindAddress);
    5356    ~Server();
     57
     58    /* helpers */
     59    void helper_ConnectToMasterserver();
     60    void helper_HandleMasterServerRequests();
     61    int replyhandler( char *addr, ENetEvent *ev );
    5462
    5563    void open();
     
    8290
    8391    float timeSinceLastUpdate_;
     92    MasterServerComm msc;
    8493  };
    8594
  • code/branches/presentation/src/libraries/network/WANDiscovery.cc

    r7737 r7739  
    4141  ManageScopedSingleton(WANDiscovery, ScopeID::Root, true);
    4242
    43   void WANDiscovery::setConfigValues()
    44   {
    45     SetConfigValue(this->msaddr, "msaddr");
    46   }
    4743
    4844  WANDiscovery::WANDiscovery()
     
    5450    RegisterObject(WANDiscovery);
    5551
    56     /* set default string for this->msaddr */
    57     this->msaddr = "localhost";
    58 
    5952    /* ... and register a config value function for it */
    6053    this->setConfigValues();
     
    6558
    6659    /* connect and see if it worked */
    67     if( msc.connect( this->msaddr.c_str(), 1234 ) )
     60    if( msc.connect( this->msaddress.c_str(), 1234 ) )
    6861      COUT(2) << "Error: could not connect to master server at "
    69         << this->msaddr << std::endl;
     62        << this->msaddress << std::endl;
    7063
    7164    /* debugging output */
    7265    COUT(4) << "Initialization of WANDiscovery complete.\n";
    7366  }
     67
     68  void WANDiscovery::setConfigValues()
     69  {
     70    SetConfigValue( msaddress, "localhost");
     71  }
    7472
    7573  WANDiscovery::~WANDiscovery()
  • code/branches/presentation/src/libraries/network/WANDiscovery.h

    r7737 r7739  
    100100
    101101      /** master server address */
    102       std::string msaddr;
     102      std::string msaddress;
    103103
    104104  }; // tolua_export
  • code/branches/presentation/src/libraries/network/packet/ServerInformation.h

    r7459 r7739  
    5050        std::string   getServerName() { return this->serverName_; }
    5151        void          setServerName(std::string name) { this->serverName_ = name; }
     52        void          setServerIP( std::string IP ) { this->serverIP_ = IP; }
    5253        uint32_t      getServerRTT() { return this->serverRTT_; }
    5354       
  • code/branches/presentation/src/orxonox/Main.cc

    r7431 r7739  
    5454    SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode");
    5555
     56    /* ADD masterserver command */
     57    SetCommandLineSwitch(masterserver).information("Start in masterserver mode");
     58
    5659    SetCommandLineArgument(generateDoc, "")
    5760        .information("Generates a Doxygen file from things like SetConsoleCommand");
     
    6770        if (CommandLineParser::getValue("generateDoc").getString().empty())
    6871        {
     72            /* TODO make this clear */
    6973            game->setStateHierarchy(
    7074            "root"
     
    9094            else if (CommandLineParser::getValue("dedicatedClient").getBool())
    9195                Game::getInstance().requestStates("client, level");
     96            /* ADD masterserver command */
     97            else if (CommandLineParser::getValue("masterserver").getBool())
     98                Game::getInstance().requestStates("masterserver");
    9299            else
    93100            {
  • code/branches/presentation/src/orxonox/gamestates/CMakeLists.txt

    r6105 r7739  
    66  GSRoot.cc
    77  GSServer.cc
     8  GSMasterServer.cc
    89  GSStandalone.cc
    910)
Note: See TracChangeset for help on using the changeset viewer.