Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3107


Ignore:
Timestamp:
May 28, 2009, 11:47:22 PM (15 years ago)
Author:
adrfried
Message:

some more work on ggzclient

Location:
code/branches/ggz
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ggz/bin/ggz/module.dsc

    r3000 r3107  
    88ProtocolVersion = 0
    99Version = 0
    10 IconPath = /home/adi/development/orxonox/media/materials/textures/orxonox_logo.svg
     10#IconPath = /home/adi/development/orxonox/media/materials/textures/orxonox_logo.svg
  • code/branches/ggz/src/orxonox/GGZClient.cc

    r3000 r3107  
    88    GGZClient* GGZClient::singletonRef_s = 0;
    99
    10     GGZClient::GGZClient()
     10    GGZClient::GGZClient(GSClient * c)
    1111        : ggzSocket(io), gameSocket(io)
    1212    {
     
    1414        singletonRef_s = this;
    1515
     16        client = c;
    1617        initGGZ();
    1718    }
     
    3839    void GGZClient::tick(const float /*dt*/)
    3940    {
     41        COUT(3) << "Tick\n";
    4042        boost::system::error_code ec;
    4143        io.poll(ec);
    42         if (ec) {
     44        if (ec)
     45        {
    4346            /* TODO: Error */
    4447        }
     
    4750    void GGZClient::initGGZ()
    4851    {
     52        COUT(3) << "Initializing GGZ\n";
    4953        ggzmod = ggzmod_new(GGZMOD_GAME);
    5054        ggzmod_set_handler(ggzmod, GGZMOD_EVENT_SERVER,
    5155                &orxonox::GGZClient::handleGGZModServer);
    52         if (ggzmod_connect(ggzmod) < 0) {
     56        if (ggzmod_connect(ggzmod) < 0)
     57        {
    5358            /* TODO: Error */
    5459        }
    5560        int fd = ggzmod_get_fd(ggzmod);
    56         if (fd < 0) {
     61        if (fd < 0)
     62        {
    5763            /* TODO: Error */
    5864        }
     
    8490            const void *data)
    8591    {
     92        COUT(3) << "GGZ Initialized\n";
    8693        ggzmod_set_state(ggzmod, GGZMOD_STATE_PLAYING);
    8794        getInstance().gameSocket.assign(boost::asio::local::stream_protocol(), *(int*)data);
  • code/branches/ggz/src/orxonox/GGZClient.h

    r3000 r3107  
    44#include "OrxonoxPrereqs.h"
    55#include "objects/Tickable.h"
     6#include "gamestates/GSClient.h"
    67
    78#include <ggzmod.h>
     
    1314    {
    1415        public:
    15             GGZClient();
     16            GGZClient(GSClient * client);
    1617            ~GGZClient();
    1718
     
    2324            static GGZClient* singletonRef_s;
    2425
     26            GSClient * client;
    2527            GGZMod * ggzmod;
    2628            boost::asio::io_service io;
  • code/branches/ggz/src/orxonox/OrxonoxPrereqs.h

    r2710 r3107  
    235235    class Scoreboard;
    236236
    237     //gui
     237    // gui
    238238    class GUIManager;
    239239
     
    248248    class GSClient;
    249249    class GSGUI;
     250
     251    // GGZ
     252    class GGZClient;
    250253}
    251254
  • code/branches/ggz/src/orxonox/gamestates/GSClient.cc

    r3106 r3107  
    3030#include "OrxonoxStableHeaders.h"
    3131#include "GSClient.h"
     32#include "SpecialConfig.h"
    3233
    3334#include "core/input/InputManager.h"
     
    4445
    4546    GSClient::GSClient()
    46         : GameState<GSGraphics>("client")
    47         , client_(0)
     47        : GameState<GSGraphics>("client"),
     48        client_(0),
     49        ggzClient(0)
    4850    {
    4951    }
     
    5860
    5961#ifdef GGZMOD_FOUND
    60         ggzClient = NULL;
    61         if (GGZClient::isActive()) {
    62             COUT(3) << "Initializing GGZ\n";
    63             ggzClient = new GGZClient;
     62        if (GGZClient::isActive())
     63        {
     64            this->ggzClient = new GGZClient(this);
     65            return;
    6466        }
    65         else {
    66             COUT(3) << "Not using GGZ\n";
    67         }
    68 #else  /* GGZMOD_FOUND */
    69         COUT(3) << "GGZ support disabled\n";
    7067#endif /* GGZMOD_FOUND */
    7168
    72         this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
     69        this->connect(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
     70    }
     71
     72    void GSClient::connect(const std::string& address, int port)
     73    {
     74        this->client_ = new Client(address, port);
    7375
    7476        if(!client_->establishConnection())
     
    8688        client_->closeConnection();
    8789
    88 #ifdef GGZMOD_FOUND
    8990        if (ggzClient)
    9091        {
    9192            delete ggzClient;
    9293        }
    93 #endif /* GGZMOD_FOUND */
    9494
    9595        // destroy client
  • code/branches/ggz/src/orxonox/gamestates/GSClient.h

    r3106 r3107  
    3030#define _GSClient_H__
    3131
    32 #include "SpecialConfig.h"
    3332#include "OrxonoxPrereqs.h"
    3433#include "network/NetworkPrereqs.h"
     
    3837namespace orxonox
    3938{
    40 #ifdef GGZMOD_FOUND
    41     class _OrxonoxExport GGZClient;
    42 #endif /* GGZMOD_FOUND */
    43 
    4439    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
    4540    {
     
    4742        GSClient();
    4843        ~GSClient();
     44        void connect(const std::string& address, int port);
    4945
    5046    private:
     
    5450
    5551        Client* client_;
    56 #ifdef GGZMOD_FOUND
    5752        GGZClient* ggzClient;
    58 #endif /* GGZMOD_FOUND */
    5953    };
    6054}
Note: See TracChangeset for help on using the changeset viewer.