Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3000 for code


Ignore:
Timestamp:
May 20, 2009, 8:47:08 PM (16 years ago)
Author:
adrfried
Message:

some ggz things

Location:
code/branches/ggz
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ggz/cmake/FindGGZ.cmake

    r2889 r3000  
    55FIND_LIBRARY(GGZMOD_LIBRARY NAMES ggzmod)
    66
    7 # handle the QUIETLY and REQUIRED arguments and set GGZ_FOUND to TRUE if
     7# handle the QUIETLY and REQUIRED arguments and set GGZMOD_FOUND to TRUE if
    88# all listed variables are TRUE
    99INCLUDE(FindPackageHandleStandardArgs)
  • code/branches/ggz/cmake/LibraryConfig.cmake

    r2889 r3000  
    116116FIND_PACKAGE(ZLIB            REQUIRED)
    117117FIND_PACKAGE(GGZ                     )
     118IF(GGZMOD_FOUND)
     119        ADD_COMPILER_FLAGS("-DHAS_GGZ")
     120ELSE(GGZMOD_FOUND)
     121        MESSAGE("GGZMOD not found, disabling GGZ support")
     122ENDIF(GGZMOD_FOUND)
    118123IF(WIN32)
    119124  FIND_PACKAGE(DirectX       REQUIRED)
  • code/branches/ggz/src/orxonox/CMakeLists.txt

    r2889 r3000  
    2020SET_SOURCE_FILES(ORXONOX_SRC_FILES
    2121  CameraManager.cc
    22   GGZClient.cc
    2322  GraphicsEngine.cc
    2423  LevelManager.cc
     
    2726  PlayerManager.cc
    2827)
     28IF(GGZMOD_FOUND)
     29        ADD_SOURCE_FILES(ORXONOX_SRC_FILES GGZClient.cc)
     30ENDIF(GGZMOD_FOUND)
    2931ADD_SUBDIRECTORY(gamestates)
    3032ADD_SUBDIRECTORY(gui)
  • code/branches/ggz/src/orxonox/GGZClient.cc

    r2997 r3000  
    22
    33#include <cassert>
     4#include <boost/bind.hpp>
    45
    56namespace orxonox
     
    1314        singletonRef_s = this;
    1415
    15         boost::asio::ip::tcp::socket::non_blocking_io non_blocking_io(true);
    16         ggzSocket.io_control(non_blocking_io);
    17         gameSocket.io_control(non_blocking_io);
    18 
    19         active = ggzmod_is_ggz_mode();
    20         if (active) {
    21             initGGZ();
    22         }
     16        initGGZ();
    2317    }
    2418
    2519    GGZClient::~GGZClient()
    2620    {
    27         if (active) {
    28             deinitGGZ();
    29         }
     21        deinitGGZ();
    3022
    3123        assert(singletonRef_s);
     
    3729        assert(singletonRef_s);
    3830        return *singletonRef_s;
     31    }
     32
     33    bool GGZClient::isActive()
     34    {
     35        return ggzmod_is_ggz_mode();
    3936    }
    4037
     
    6158        }
    6259        /* TODO: Error */
    63         ggzSocket.assign(boost::asio::ip::tcp::v4(), fd);
    64         ggzSocket.async_read_some(boost::asio::null_buffers(), handleGGZ);
     60        ggzSocket.assign(boost::asio::local::stream_protocol(), fd);
     61        ggzSocket.async_read_some(boost::asio::null_buffers(), boost::bind(&handleGGZ, boost::asio::placeholders::error));
    6562    }
    6663
     
    7269
    7370    /* Got data from game server */
    74     void handleGame(const boost::system::error_code& /*e*/)
     71    void GGZClient::handleGame(const boost::system::error_code& /*e*/)
    7572    {
    7673        /* TODO: read from gameSocket */
     
    8885    {
    8986        ggzmod_set_state(ggzmod, GGZMOD_STATE_PLAYING);
    90         gameSocket.assign(boost::asio::ip::tcp::v4(), *(int*)data);
    91         gameSocket.async_read_some(boost::asio::null_buffers(), handleGame);
     87        getInstance().gameSocket.assign(boost::asio::local::stream_protocol(), *(int*)data);
     88        getInstance().gameSocket.async_read_some(boost::asio::null_buffers(), boost::bind(&handleGame, boost::asio::placeholders::error));
    9289    }
    9390}
  • code/branches/ggz/src/orxonox/GGZClient.h

    r2997 r3000  
    1717
    1818            static GGZClient& getInstance();
     19            static bool isActive();
    1920            virtual void tick(const float dt);
    2021
     
    2223            static GGZClient* singletonRef_s;
    2324
    24             bool active;
    2525            GGZMod * ggzmod;
    2626            boost::asio::io_service io;
    27             boost::asio::ip::tcp::socket ggzSocket;
    28             boost::asio::ip::tcp::socket gameSocket;
     27            boost::asio::local::stream_protocol::socket ggzSocket;
     28            boost::asio::local::stream_protocol::socket gameSocket;
    2929
    3030            void initGGZ();
    3131            void deinitGGZ();
    32             void handleGame(const boost::system::error_code& e);
    33             void handleGGZ(const boost::system::error_code& e);
     32            static void handleGame(const boost::system::error_code& e);
     33            static void handleGGZ(const boost::system::error_code& e);
    3434            static void handleGGZModServer(GGZMod * ggzmod, GGZModEvent e,
    3535                    const void *data);
  • code/branches/ggz/src/orxonox/gamestates/GSClient.cc

    r2171 r3000  
    2424 *   Co-authors:
    2525 *      Fabian 'x3n' Landau
     26 *      Adrian Friedli
    2627 *
    2728 */
     
    5354        Core::setIsClient(true);
    5455
     56#ifdef HAS_GGZ
     57        ggzClient = NULL;
     58        if (GGZClient::isActive()) {
     59            COUT(3) << "Initializing GGZ\n";
     60            ggzClient = new GGZClient;
     61        }
     62        else {
     63            COUT(3) << "Not using GGZ\n";
     64        }
     65#else  /* HAS_GGZ */
     66        COUT(3) << "GGZ support disabled\n";
     67#endif /* HAS_GGZ */
     68
    5569        this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
    5670
     
    6983        client_->closeConnection();
    7084
     85#ifdef HAS_GGZ
     86        if (ggzClient)
     87        {
     88            delete ggzClient;
     89        }
     90#endif /* HAS_GGZ */
     91
    7192        // destroy client
    7293        delete this->client_;
  • code/branches/ggz/src/orxonox/gamestates/GSClient.h

    r2171 r3000  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Adrian Friedli
    2626 *
    2727 */
     
    3434#include "GSLevel.h"
    3535#include "GSGraphics.h"
     36#ifdef HAS_GGZ
     37#include "GGZClient.h"
     38#endif /* HAS_GGZ */
    3639
    3740namespace orxonox
     
    5053
    5154        Client* client_;
     55#ifdef HAS_GGZ
     56        GGZClient* ggzClient;
     57#endif /* HAS_GGZ */
     58
    5259    };
    5360}
Note: See TracChangeset for help on using the changeset viewer.