[Orxonox-commit 1019] r5740 - in code/branches/ggz2: . bin bin/ggz cmake src src/modules/gamestates src/orxonox

landauf at orxonox.net landauf at orxonox.net
Tue Sep 1 17:35:16 CEST 2009


Author: landauf
Date: 2009-09-01 17:35:16 +0200 (Tue, 01 Sep 2009)
New Revision: 5740

Added:
   code/branches/ggz2/bin/ggz/
   code/branches/ggz2/bin/ggz/module.dsc
   code/branches/ggz2/bin/ggz/orxonox.dsc
   code/branches/ggz2/bin/ggz/orxonox.room
   code/branches/ggz2/cmake/FindGGZ.cmake
   code/branches/ggz2/src/orxonox/GGZClient.cc
   code/branches/ggz2/src/orxonox/GGZClient.h
Removed:
   code/branches/ggz2/bin/ggz/module.dsc
   code/branches/ggz2/bin/ggz/orxonox.dsc
   code/branches/ggz2/bin/ggz/orxonox.room
Modified:
   code/branches/ggz2/
   code/branches/ggz2/cmake/LibraryConfig.cmake
   code/branches/ggz2/src/SpecialConfig.h.in
   code/branches/ggz2/src/modules/gamestates/GSClient.cc
   code/branches/ggz2/src/modules/gamestates/GSClient.h
   code/branches/ggz2/src/orxonox/CMakeLists.txt
   code/branches/ggz2/src/orxonox/OrxonoxPrereqs.h
Log:
merged ggz into ggz2


Property changes on: code/branches/ggz2
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/resource2:3372-5694
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890
   + /code/branches/ggz:2798-5739
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/resource2:3372-5694
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890

Deleted: code/branches/ggz2/bin/ggz/module.dsc
===================================================================
--- code/branches/ggz/bin/ggz/module.dsc	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/bin/ggz/module.dsc	2009-09-01 15:35:16 UTC (rev 5740)
@@ -1,10 +0,0 @@
-[ModuleInfo]
-Author = Orxonox Developers
-CommandLine = /home/adi/development/orxonox/orxonox/build/bin/orxonox --state client
-Frontend = ogre
-Homepage = http://www.orxonox.net/
-Name = Orxonox
-ProtocolEngine = Orxonox
-ProtocolVersion = 0
-Version = 0
-#IconPath = /home/adi/development/orxonox/media/materials/textures/orxonox_logo.svg

Copied: code/branches/ggz2/bin/ggz/module.dsc (from rev 5739, code/branches/ggz/bin/ggz/module.dsc)
===================================================================
--- code/branches/ggz2/bin/ggz/module.dsc	                        (rev 0)
+++ code/branches/ggz2/bin/ggz/module.dsc	2009-09-01 15:35:16 UTC (rev 5740)
@@ -0,0 +1,10 @@
+[ModuleInfo]
+Author = Orxonox Developers
+CommandLine = /home/adi/development/orxonox/orxonox/build/bin/orxonox --state client
+Frontend = ogre
+Homepage = http://www.orxonox.net/
+Name = Orxonox
+ProtocolEngine = Orxonox
+ProtocolVersion = 0
+Version = 0
+#IconPath = /home/adi/development/orxonox/media/materials/textures/orxonox_logo.svg


Property changes on: code/branches/ggz2/bin/ggz/module.dsc
___________________________________________________________________
Added: svn:eol-style
   + native

Deleted: code/branches/ggz2/bin/ggz/orxonox.dsc
===================================================================
--- code/branches/ggz/bin/ggz/orxonox.dsc	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/bin/ggz/orxonox.dsc	2009-09-01 15:35:16 UTC (rev 5740)
@@ -1,27 +0,0 @@
-[GameInfo]
-Author = Orxonox Developers
-Description = Space Shooter
-Homepage = http://www.orxonox.net/
-Name = Orxonox
-Version = 0
-
-[LaunchInfo]
-ExecutablePath = /home/adi/development/orxonox/orxonox/build/bin/orxonox --state standalone
-
-[Protocol]
-Engine = Orxonox
-Version = 0
-
-[TableOptions]
-AllowLeave = 1
-BotsAllowed = 1..16
-PlayersAllowed = 1..16
-KillWhenEmpty = 0
-AllowSpectators = 1
-AllowRestore = 1
-AllowPeers = 1
-
-[Statistics]
-Records = 0
-Ratings = 0
-Highscore = 0

Copied: code/branches/ggz2/bin/ggz/orxonox.dsc (from rev 5739, code/branches/ggz/bin/ggz/orxonox.dsc)
===================================================================
--- code/branches/ggz2/bin/ggz/orxonox.dsc	                        (rev 0)
+++ code/branches/ggz2/bin/ggz/orxonox.dsc	2009-09-01 15:35:16 UTC (rev 5740)
@@ -0,0 +1,27 @@
+[GameInfo]
+Author = Orxonox Developers
+Description = Space Shooter
+Homepage = http://www.orxonox.net/
+Name = Orxonox
+Version = 0
+
+[LaunchInfo]
+ExecutablePath = /home/adi/development/orxonox/orxonox/build/bin/orxonox --state standalone
+
+[Protocol]
+Engine = Orxonox
+Version = 0
+
+[TableOptions]
+AllowLeave = 1
+BotsAllowed = 1..16
+PlayersAllowed = 1..16
+KillWhenEmpty = 0
+AllowSpectators = 1
+AllowRestore = 1
+AllowPeers = 1
+
+[Statistics]
+Records = 0
+Ratings = 0
+Highscore = 0


Property changes on: code/branches/ggz2/bin/ggz/orxonox.dsc
___________________________________________________________________
Added: svn:eol-style
   + native

Deleted: code/branches/ggz2/bin/ggz/orxonox.room
===================================================================
--- code/branches/ggz/bin/ggz/orxonox.room	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/bin/ggz/orxonox.room	2009-09-01 15:35:16 UTC (rev 5740)
@@ -1,7 +0,0 @@
-[RoomInfo]
-Name = Orxonox
-Description = Space Shooter
-GameType = Orxonox
-MaxPlayers = 32
-MaxTables = 32
-EntryRestriction = none

Copied: code/branches/ggz2/bin/ggz/orxonox.room (from rev 5739, code/branches/ggz/bin/ggz/orxonox.room)
===================================================================
--- code/branches/ggz2/bin/ggz/orxonox.room	                        (rev 0)
+++ code/branches/ggz2/bin/ggz/orxonox.room	2009-09-01 15:35:16 UTC (rev 5740)
@@ -0,0 +1,7 @@
+[RoomInfo]
+Name = Orxonox
+Description = Space Shooter
+GameType = Orxonox
+MaxPlayers = 32
+MaxTables = 32
+EntryRestriction = none


Property changes on: code/branches/ggz2/bin/ggz/orxonox.room
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: code/branches/ggz2/cmake/FindGGZ.cmake (from rev 5739, code/branches/ggz/cmake/FindGGZ.cmake)
===================================================================
--- code/branches/ggz2/cmake/FindGGZ.cmake	                        (rev 0)
+++ code/branches/ggz2/cmake/FindGGZ.cmake	2009-09-01 15:35:16 UTC (rev 5740)
@@ -0,0 +1,16 @@
+# Find GGZ
+
+FIND_PATH(GGZ_INCLUDE_DIR ggzmod.h)
+
+FIND_LIBRARY(GGZMOD_LIBRARY NAMES ggzmod)
+
+# handle the QUIETLY and REQUIRED arguments and set GGZMOD_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GGZMOD DEFAULT_MSG GGZMOD_LIBRARY GGZ_INCLUDE_DIR)
+
+IF(GGZMOD_FOUND)
+  SET(GGZMOD_LIBRARIES ${GGZMOD_LIBRARY})
+ENDIF(GGZMOD_FOUND)
+
+MARK_AS_ADVANCED(GGZMOD_LIBRARY GGZMOD_LIBRARIES GGZ_INCLUDE_DIR)


Property changes on: code/branches/ggz2/cmake/FindGGZ.cmake
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: code/branches/ggz2/cmake/LibraryConfig.cmake
===================================================================
--- code/branches/ggz2/cmake/LibraryConfig.cmake	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/cmake/LibraryConfig.cmake	2009-09-01 15:35:16 UTC (rev 5740)
@@ -90,6 +90,10 @@
 FIND_PACKAGE(Vorbis          REQUIRED)
 FIND_PACKAGE(ALUT            REQUIRED)
 FIND_PACKAGE(ZLIB            REQUIRED)
+FIND_PACKAGE(GGZ                     )
+IF(NOT GGZMOD_FOUND)
+  MESSAGE(STATUS "GGZMOD not found, disabling GGZ support")
+ENDIF(NOT GGZMOD_FOUND)
 IF(WIN32)
   FIND_PACKAGE(DirectX       REQUIRED)
 ENDIF(WIN32)

Modified: code/branches/ggz2/src/SpecialConfig.h.in
===================================================================
--- code/branches/ggz2/src/SpecialConfig.h.in	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/src/SpecialConfig.h.in	2009-09-01 15:35:16 UTC (rev 5740)
@@ -68,6 +68,12 @@
 */
 #cmakedefine CMAKE_CONFIGURATION_TYPES
 
+/**
+ at def GGZMOD_FOUND
+    Macro for availability of the ggzmod library
+*/
+#cmakedefine GGZMOD_FOUND
+
 // Handle default ConfigValues
 namespace orxonox { namespace specialConfig
 {

Modified: code/branches/ggz2/src/modules/gamestates/GSClient.cc
===================================================================
--- code/branches/ggz2/src/modules/gamestates/GSClient.cc	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/src/modules/gamestates/GSClient.cc	2009-09-01 15:35:16 UTC (rev 5740)
@@ -23,10 +23,12 @@
  *      Reto Grieder
  *   Co-authors:
  *      Fabian 'x3n' Landau
+ *      Adrian Friedli
  *
  */
 
 #include "GSClient.h"
+#include "SpecialConfig.h"
 
 #include "util/Exception.h"
 #include "core/Clock.h"
@@ -34,6 +36,9 @@
 #include "core/Game.h"
 #include "core/GameMode.h"
 #include "network/Client.h"
+#ifdef GGZMOD_FOUND
+#include "GGZClient.h"
+#endif /* GGZMOD_FOUND */
 
 namespace orxonox
 {
@@ -44,6 +49,7 @@
     GSClient::GSClient(const GameStateInfo& info)
         : GameState(info)
         , client_(0)
+        , ggzClient(0)
     {
     }
 
@@ -55,8 +61,21 @@
     {
         GameMode::setIsClient(true);
 
-        this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
+#ifdef GGZMOD_FOUND
+        if (GGZClient::isActive())
+        {
+            this->ggzClient = new GGZClient(this);
+            return;
+        }
+#endif /* GGZMOD_FOUND */
 
+        this->connect(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
+    }
+
+    void GSClient::connect(const std::string& address, int port)
+    {
+        this->client_ = new Client(address, port);
+
         if(!client_->establishConnection())
             ThrowException(InitialisationFailed, "Could not establish connection with server.");
 
@@ -67,6 +86,13 @@
     {
         client_->closeConnection();
 
+#ifdef GGZMOD_FOUND
+        if (ggzClient)
+        {
+            delete ggzClient;
+        }
+#endif /* GGZMOD_FOUND */
+
         // destroy client
         delete this->client_;
 
@@ -75,6 +101,9 @@
 
     void GSClient::update(const Clock& time)
     {
-        client_->update(time);
+        if (client_)
+        {
+            client_->update(time);
+        }
     }
 }

Modified: code/branches/ggz2/src/modules/gamestates/GSClient.h
===================================================================
--- code/branches/ggz2/src/modules/gamestates/GSClient.h	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/src/modules/gamestates/GSClient.h	2009-09-01 15:35:16 UTC (rev 5740)
@@ -22,7 +22,7 @@
  *   Author:
  *      Reto Grieder
  *   Co-authors:
- *      ...
+ *      Adrian Friedli
  *
  */
 
@@ -41,6 +41,7 @@
     public:
         GSClient(const GameStateInfo& info);
         ~GSClient();
+        void connect(const std::string& address, int port);
 
         void activate();
         void deactivate();
@@ -48,6 +49,7 @@
 
     private:
         Client* client_;
+        GGZClient* ggzClient;
     };
 }
 

Modified: code/branches/ggz2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/ggz2/src/orxonox/CMakeLists.txt	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/src/orxonox/CMakeLists.txt	2009-09-01 15:35:16 UTC (rev 5740)
@@ -30,6 +30,10 @@
   Scene.cc
 )
 
+IF(GGZMOD_FOUND)
+  ADD_SOURCE_FILES(ORXONOX_SRC_FILES GGZClient.cc)
+ENDIF(GGZMOD_FOUND)
+
 ADD_SUBDIRECTORY(collisionshapes)
 ADD_SUBDIRECTORY(controllers)
 ADD_SUBDIRECTORY(gametypes)
@@ -64,6 +68,7 @@
     ${VORBISFILE_LIBRARY}
     ${VORBIS_LIBRARY}
     ${OGG_LIBRARY}
+    ${GGZMOD_LIBRARIES}
     tinyxml++_orxonox
     tolua++_orxonox
     bullet_orxonox

Copied: code/branches/ggz2/src/orxonox/GGZClient.cc (from rev 5739, code/branches/ggz/src/orxonox/GGZClient.cc)
===================================================================
--- code/branches/ggz2/src/orxonox/GGZClient.cc	                        (rev 0)
+++ code/branches/ggz2/src/orxonox/GGZClient.cc	2009-09-01 15:35:16 UTC (rev 5740)
@@ -0,0 +1,96 @@
+#include "GGZClient.h"
+
+#include <cassert>
+#include <boost/bind.hpp>
+
+namespace orxonox
+{
+    GGZClient* GGZClient::singletonRef_s = 0;
+
+    GGZClient::GGZClient(GSClient * c)
+        : ggzSocket(io), gameSocket(io)
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        client = c;
+        initGGZ();
+    }
+
+    GGZClient::~GGZClient()
+    {
+        deinitGGZ();
+
+        assert(singletonRef_s);
+        singletonRef_s = 0;
+    }
+
+    GGZClient& GGZClient::getInstance()
+    {
+        assert(singletonRef_s);
+        return *singletonRef_s;
+    }
+
+    bool GGZClient::isActive()
+    {
+        return ggzmod_is_ggz_mode();
+    }
+
+    void GGZClient::tick(const float /*dt*/)
+    {
+        boost::system::error_code ec;
+        io.poll(ec);
+        if (ec)
+        {
+            /* TODO: Error */
+        }
+    }
+
+    void GGZClient::initGGZ()
+    {
+        COUT(3) << "Initializing GGZ\n";
+        ggzmod = ggzmod_new(GGZMOD_GAME);
+        ggzmod_set_handler(ggzmod, GGZMOD_EVENT_SERVER,
+                &orxonox::GGZClient::handleGGZModServer);
+        if (ggzmod_connect(ggzmod) < 0)
+        {
+            /* TODO: Error */
+        }
+        int fd = ggzmod_get_fd(ggzmod);
+        if (fd < 0)
+        {
+            /* TODO: Error */
+        }
+        /* TODO: Error */
+        ggzSocket.assign(boost::asio::local::stream_protocol(), fd);
+        ggzSocket.async_read_some(boost::asio::null_buffers(), boost::bind(&handleGGZ, boost::asio::placeholders::error));
+    }
+
+    void GGZClient::deinitGGZ()
+    {
+        ggzmod_disconnect(ggzmod);
+        ggzmod_free(ggzmod);
+    }
+
+    /* Got data from game server */
+    void GGZClient::handleGame(const boost::system::error_code& /*e*/)
+    {
+        /* TODO: read from gameSocket */
+    }
+
+    /* Got data from GGZ */
+    void GGZClient::handleGGZ(const boost::system::error_code& /*e*/)
+    {
+        ggzmod_dispatch(getInstance().ggzmod);
+    }
+
+    /* Connection to game server established */
+    void GGZClient::handleGGZModServer(GGZMod * ggzmod, GGZModEvent e,
+            const void *data)
+    {
+        COUT(3) << "GGZ Initialized\n";
+        ggzmod_set_state(ggzmod, GGZMOD_STATE_PLAYING);
+        getInstance().gameSocket.assign(boost::asio::local::stream_protocol(), *(int*)data);
+        getInstance().gameSocket.async_read_some(boost::asio::null_buffers(), boost::bind(&handleGame, boost::asio::placeholders::error));
+    }
+}


Property changes on: code/branches/ggz2/src/orxonox/GGZClient.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: code/branches/ggz2/src/orxonox/GGZClient.h (from rev 5739, code/branches/ggz/src/orxonox/GGZClient.h)
===================================================================
--- code/branches/ggz2/src/orxonox/GGZClient.h	                        (rev 0)
+++ code/branches/ggz2/src/orxonox/GGZClient.h	2009-09-01 15:35:16 UTC (rev 5740)
@@ -0,0 +1,41 @@
+#ifndef _GGZClient_H__
+#define _GGZClient_H__
+
+#include "OrxonoxPrereqs.h"
+#include "objects/Tickable.h"
+#include "gamestates/GSClient.h"
+
+#include <ggzmod.h>
+#include <boost/asio.hpp>
+
+namespace orxonox
+{
+    class _OrxonoxExport GGZClient : public Tickable
+    {
+        public:
+            GGZClient(GSClient * client);
+            ~GGZClient();
+
+            static GGZClient& getInstance();
+            static bool isActive();
+            virtual void tick(const float dt);
+
+        private:
+            static GGZClient* singletonRef_s;
+
+            GSClient * client;
+            GGZMod * ggzmod;
+            boost::asio::io_service io;
+            boost::asio::local::stream_protocol::socket ggzSocket;
+            boost::asio::local::stream_protocol::socket gameSocket;
+
+            void initGGZ();
+            void deinitGGZ();
+            static void handleGame(const boost::system::error_code& e);
+            static void handleGGZ(const boost::system::error_code& e);
+            static void handleGGZModServer(GGZMod * ggzmod, GGZModEvent e,
+                    const void *data);
+    };
+}
+
+#endif /* _GGZClient_H__ */


Property changes on: code/branches/ggz2/src/orxonox/GGZClient.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: code/branches/ggz2/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/ggz2/src/orxonox/OrxonoxPrereqs.h	2009-09-01 15:10:23 UTC (rev 5739)
+++ code/branches/ggz2/src/orxonox/OrxonoxPrereqs.h	2009-09-01 15:35:16 UTC (rev 5740)
@@ -192,6 +192,9 @@
     class SoundBase;
     class SoundManager;
     class SoundMainMenu;
+
+    // GGZ
+    class GGZClient;
 }
 
 // Bullet Physics Engine




More information about the Orxonox-commit mailing list