[Orxonox-commit 3031] r7727 - in code/branches/masterserver/src/orxonox: . gamestates

smerkli at orxonox.net smerkli at orxonox.net
Wed Dec 8 13:49:39 CET 2010


Author: smerkli
Date: 2010-12-08 13:49:39 +0100 (Wed, 08 Dec 2010)
New Revision: 7727

Added:
   code/branches/masterserver/src/orxonox/gamestates/GSMasterServer.cc
   code/branches/masterserver/src/orxonox/gamestates/GSMasterServer.h
Modified:
   code/branches/masterserver/src/orxonox/Main.cc
Log:
Before conversion of masterserver from module to library

Modified: code/branches/masterserver/src/orxonox/Main.cc
===================================================================
--- code/branches/masterserver/src/orxonox/Main.cc	2010-12-08 12:27:51 UTC (rev 7726)
+++ code/branches/masterserver/src/orxonox/Main.cc	2010-12-08 12:49:39 UTC (rev 7727)
@@ -53,6 +53,9 @@
     SetCommandLineSwitch(standalone).information("Start in standalone mode");
     SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode");
 
+    /* ADD masterserver command */
+    SetCommandLineSwitch(masterserver).information("Start in masterserver mode");
+
     SetCommandLineArgument(generateDoc, "")
         .information("Generates a Doxygen file from things like SetConsoleCommand");
 
@@ -66,6 +69,7 @@
 
         if (CommandLineParser::getValue("generateDoc").getString().empty())
         {
+            /* TODO make this clear */
             game->setStateHierarchy(
             "root"
             " graphics"
@@ -74,6 +78,7 @@
             "   level"
             " server,client"
             "  level"
+            " masterserver"
             );
 
             game->requestState("root");
@@ -89,8 +94,9 @@
                 Game::getInstance().requestStates("server, level");
             else if (CommandLineParser::getValue("dedicatedClient").getBool())
                 Game::getInstance().requestStates("client, level");
-            //else if (CommandLineParser::getValue("masterserver").getBool())
-                //Game::getInstance().requestStates("client, level");
+            /* ADD masterserver command */
+            else if (CommandLineParser::getValue("masterserver").getBool())
+                Game::getInstance().requestStates("masterserver");
             else
             {
                 if (!CommandLineParser::getValue("console").getBool())

Copied: code/branches/masterserver/src/orxonox/gamestates/GSMasterServer.cc (from rev 7725, code/branches/masterserver/src/orxonox/gamestates/GSServer.cc)
===================================================================
--- code/branches/masterserver/src/orxonox/gamestates/GSMasterServer.cc	                        (rev 0)
+++ code/branches/masterserver/src/orxonox/gamestates/GSMasterServer.cc	2010-12-08 12:49:39 UTC (rev 7727)
@@ -0,0 +1,76 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it 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.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Sandro 'smerkli' Merkli 
+ *   Co-authors:
+ *      Reto Grieder (original file for GSServer.cc)
+ *      Fabian 'x3n' Landau (original file for GSServer.cc)
+ *
+ */
+
+#include "GSMasterServer.h"
+
+#include "util/Debug.h"
+#include "core/CommandLineParser.h"
+#include "core/Game.h"
+#include "core/GameMode.h"
+#include "network/Server.h"
+
+namespace orxonox
+{
+    DeclareGameState(GSMasterServer, "masterserver", false, false);
+
+    SetCommandLineArgument(port, 55566).shortcut("p").information("Network communication port to be used 0-65535 (default: 55566)");
+
+    GSMasterServer::GSMasterServer(const GameStateInfo& info)
+        : GameState(info)
+        , server_(0)
+    {
+    }
+
+    GSMasterServer::~GSMasterServer()
+    {
+    }
+
+    void GSMasterServer::activate()
+    {
+        GameMode::setIsServer(true);
+
+        this->server_ = new Server(CommandLineParser::getValue("port"));
+        COUT(0) << "Loading scene in server mode" << std::endl;
+
+        server_->open();
+    }
+
+    void GSMasterServer::deactivate()
+    {
+        this->server_->close();
+        delete this->server_;
+
+        GameMode::setIsServer(false);
+    }
+
+    void GSMasterServer::update(const Clock& time)
+    {
+        server_->update(time);
+    }
+}

Copied: code/branches/masterserver/src/orxonox/gamestates/GSMasterServer.h (from rev 7725, code/branches/masterserver/src/orxonox/gamestates/GSServer.h)
===================================================================
--- code/branches/masterserver/src/orxonox/gamestates/GSMasterServer.h	                        (rev 0)
+++ code/branches/masterserver/src/orxonox/gamestates/GSMasterServer.h	2010-12-08 12:49:39 UTC (rev 7727)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it 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.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Sandro 'smerkli' Merkli 
+ *   Co-authors:
+ *      Reto Grieder (Original GSServer.h file this was adapted from)
+ *      ...
+ *
+ */
+
+#ifndef _GSMasterServer_H__
+#define _GSMasterServer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/GameState.h"
+#include "network/NetworkPrereqs.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSMasterServer : public GameState
+    {
+    public:
+        GSMasterServer(const GameStateInfo& info);
+        ~GSMasterServer();
+
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
+
+    private:
+        
+    };
+}
+
+#endif /* _GSServer_H__ */




More information about the Orxonox-commit mailing list