[Orxonox-commit 574] r3107 - in branches/ggz: bin/ggz src/orxonox src/orxonox/gamestates
adrfried at orxonox.net
adrfried at orxonox.net
Thu May 28 23:47:22 CEST 2009
Author: adrfried
Date: 2009-05-28 23:47:22 +0200 (Thu, 28 May 2009)
New Revision: 3107
Modified:
branches/ggz/bin/ggz/module.dsc
branches/ggz/src/orxonox/GGZClient.cc
branches/ggz/src/orxonox/GGZClient.h
branches/ggz/src/orxonox/OrxonoxPrereqs.h
branches/ggz/src/orxonox/gamestates/GSClient.cc
branches/ggz/src/orxonox/gamestates/GSClient.h
Log:
some more work on ggzclient
Modified: branches/ggz/bin/ggz/module.dsc
===================================================================
--- branches/ggz/bin/ggz/module.dsc 2009-05-28 15:18:42 UTC (rev 3106)
+++ branches/ggz/bin/ggz/module.dsc 2009-05-28 21:47:22 UTC (rev 3107)
@@ -7,4 +7,4 @@
ProtocolEngine = Orxonox
ProtocolVersion = 0
Version = 0
-IconPath = /home/adi/development/orxonox/media/materials/textures/orxonox_logo.svg
+#IconPath = /home/adi/development/orxonox/media/materials/textures/orxonox_logo.svg
Modified: branches/ggz/src/orxonox/GGZClient.cc
===================================================================
--- branches/ggz/src/orxonox/GGZClient.cc 2009-05-28 15:18:42 UTC (rev 3106)
+++ branches/ggz/src/orxonox/GGZClient.cc 2009-05-28 21:47:22 UTC (rev 3107)
@@ -7,12 +7,13 @@
{
GGZClient* GGZClient::singletonRef_s = 0;
- GGZClient::GGZClient()
+ GGZClient::GGZClient(GSClient * c)
: ggzSocket(io), gameSocket(io)
{
assert(singletonRef_s == 0);
singletonRef_s = this;
+ client = c;
initGGZ();
}
@@ -37,23 +38,28 @@
void GGZClient::tick(const float /*dt*/)
{
+ COUT(3) << "Tick\n";
boost::system::error_code ec;
io.poll(ec);
- if (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) {
+ if (ggzmod_connect(ggzmod) < 0)
+ {
/* TODO: Error */
}
int fd = ggzmod_get_fd(ggzmod);
- if (fd < 0) {
+ if (fd < 0)
+ {
/* TODO: Error */
}
/* TODO: Error */
@@ -83,6 +89,7 @@
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));
Modified: branches/ggz/src/orxonox/GGZClient.h
===================================================================
--- branches/ggz/src/orxonox/GGZClient.h 2009-05-28 15:18:42 UTC (rev 3106)
+++ branches/ggz/src/orxonox/GGZClient.h 2009-05-28 21:47:22 UTC (rev 3107)
@@ -3,6 +3,7 @@
#include "OrxonoxPrereqs.h"
#include "objects/Tickable.h"
+#include "gamestates/GSClient.h"
#include <ggzmod.h>
#include <boost/asio.hpp>
@@ -12,7 +13,7 @@
class _OrxonoxExport GGZClient : public Tickable
{
public:
- GGZClient();
+ GGZClient(GSClient * client);
~GGZClient();
static GGZClient& getInstance();
@@ -22,6 +23,7 @@
private:
static GGZClient* singletonRef_s;
+ GSClient * client;
GGZMod * ggzmod;
boost::asio::io_service io;
boost::asio::local::stream_protocol::socket ggzSocket;
Modified: branches/ggz/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/ggz/src/orxonox/OrxonoxPrereqs.h 2009-05-28 15:18:42 UTC (rev 3106)
+++ branches/ggz/src/orxonox/OrxonoxPrereqs.h 2009-05-28 21:47:22 UTC (rev 3107)
@@ -234,7 +234,7 @@
class CreateLines;
class Scoreboard;
- //gui
+ // gui
class GUIManager;
// game states
@@ -247,6 +247,9 @@
class GSServer;
class GSClient;
class GSGUI;
+
+ // GGZ
+ class GGZClient;
}
namespace Ogre
Modified: branches/ggz/src/orxonox/gamestates/GSClient.cc
===================================================================
--- branches/ggz/src/orxonox/gamestates/GSClient.cc 2009-05-28 15:18:42 UTC (rev 3106)
+++ branches/ggz/src/orxonox/gamestates/GSClient.cc 2009-05-28 21:47:22 UTC (rev 3107)
@@ -29,6 +29,7 @@
#include "OrxonoxStableHeaders.h"
#include "GSClient.h"
+#include "SpecialConfig.h"
#include "core/input/InputManager.h"
#include "core/CommandLine.h"
@@ -43,8 +44,9 @@
SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
GSClient::GSClient()
- : GameState<GSGraphics>("client")
- , client_(0)
+ : GameState<GSGraphics>("client"),
+ client_(0),
+ ggzClient(0)
{
}
@@ -57,20 +59,20 @@
Core::setIsClient(true);
#ifdef GGZMOD_FOUND
- ggzClient = NULL;
- if (GGZClient::isActive()) {
- COUT(3) << "Initializing GGZ\n";
- ggzClient = new GGZClient;
+ if (GGZClient::isActive())
+ {
+ this->ggzClient = new GGZClient(this);
+ return;
}
- else {
- COUT(3) << "Not using GGZ\n";
- }
-#else /* GGZMOD_FOUND */
- COUT(3) << "GGZ support disabled\n";
#endif /* GGZMOD_FOUND */
- this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
+ 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.");
@@ -85,12 +87,10 @@
client_->closeConnection();
-#ifdef GGZMOD_FOUND
if (ggzClient)
{
delete ggzClient;
}
-#endif /* GGZMOD_FOUND */
// destroy client
delete this->client_;
Modified: branches/ggz/src/orxonox/gamestates/GSClient.h
===================================================================
--- branches/ggz/src/orxonox/gamestates/GSClient.h 2009-05-28 15:18:42 UTC (rev 3106)
+++ branches/ggz/src/orxonox/gamestates/GSClient.h 2009-05-28 21:47:22 UTC (rev 3107)
@@ -29,7 +29,6 @@
#ifndef _GSClient_H__
#define _GSClient_H__
-#include "SpecialConfig.h"
#include "OrxonoxPrereqs.h"
#include "network/NetworkPrereqs.h"
#include "GSLevel.h"
@@ -37,15 +36,12 @@
namespace orxonox
{
-#ifdef GGZMOD_FOUND
- class _OrxonoxExport GGZClient;
-#endif /* GGZMOD_FOUND */
-
class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
{
public:
GSClient();
~GSClient();
+ void connect(const std::string& address, int port);
private:
void enter();
@@ -53,9 +49,7 @@
void ticked(const Clock& time);
Client* client_;
-#ifdef GGZMOD_FOUND
GGZClient* ggzClient;
-#endif /* GGZMOD_FOUND */
};
}
More information about the Orxonox-commit
mailing list