[Orxonox-commit 417] r3000 - in branches/ggz: bin bin/ggz cmake src/orxonox src/orxonox/gamestates
adrfried at orxonox.net
adrfried at orxonox.net
Wed May 20 20:47:08 CEST 2009
Author: adrfried
Date: 2009-05-20 20:47:08 +0200 (Wed, 20 May 2009)
New Revision: 3000
Added:
branches/ggz/bin/ggz/
branches/ggz/bin/ggz/module.dsc
branches/ggz/bin/ggz/orxonox.dsc
branches/ggz/bin/ggz/orxonox.room
Modified:
branches/ggz/cmake/FindGGZ.cmake
branches/ggz/cmake/LibraryConfig.cmake
branches/ggz/src/orxonox/CMakeLists.txt
branches/ggz/src/orxonox/GGZClient.cc
branches/ggz/src/orxonox/GGZClient.h
branches/ggz/src/orxonox/gamestates/GSClient.cc
branches/ggz/src/orxonox/gamestates/GSClient.h
Log:
some ggz things
Added: branches/ggz/bin/ggz/module.dsc
===================================================================
--- branches/ggz/bin/ggz/module.dsc (rev 0)
+++ branches/ggz/bin/ggz/module.dsc 2009-05-20 18:47:08 UTC (rev 3000)
@@ -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
Added: branches/ggz/bin/ggz/orxonox.dsc
===================================================================
--- branches/ggz/bin/ggz/orxonox.dsc (rev 0)
+++ branches/ggz/bin/ggz/orxonox.dsc 2009-05-20 18:47:08 UTC (rev 3000)
@@ -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
Added: branches/ggz/bin/ggz/orxonox.room
===================================================================
--- branches/ggz/bin/ggz/orxonox.room (rev 0)
+++ branches/ggz/bin/ggz/orxonox.room 2009-05-20 18:47:08 UTC (rev 3000)
@@ -0,0 +1,7 @@
+[RoomInfo]
+Name = Orxonox
+Description = Space Shooter
+GameType = Orxonox
+MaxPlayers = 32
+MaxTables = 32
+EntryRestriction = none
Modified: branches/ggz/cmake/FindGGZ.cmake
===================================================================
--- branches/ggz/cmake/FindGGZ.cmake 2009-05-20 18:45:29 UTC (rev 2999)
+++ branches/ggz/cmake/FindGGZ.cmake 2009-05-20 18:47:08 UTC (rev 3000)
@@ -4,7 +4,7 @@
FIND_LIBRARY(GGZMOD_LIBRARY NAMES ggzmod)
-# handle the QUIETLY and REQUIRED arguments and set GGZ_FOUND to TRUE if
+# 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)
Modified: branches/ggz/cmake/LibraryConfig.cmake
===================================================================
--- branches/ggz/cmake/LibraryConfig.cmake 2009-05-20 18:45:29 UTC (rev 2999)
+++ branches/ggz/cmake/LibraryConfig.cmake 2009-05-20 18:47:08 UTC (rev 3000)
@@ -115,6 +115,11 @@
FIND_PACKAGE(ALUT REQUIRED)
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(GGZ )
+IF(GGZMOD_FOUND)
+ ADD_COMPILER_FLAGS("-DHAS_GGZ")
+ELSE(GGZMOD_FOUND)
+ MESSAGE("GGZMOD not found, disabling GGZ support")
+ENDIF(GGZMOD_FOUND)
IF(WIN32)
FIND_PACKAGE(DirectX REQUIRED)
ENDIF(WIN32)
Modified: branches/ggz/src/orxonox/CMakeLists.txt
===================================================================
--- branches/ggz/src/orxonox/CMakeLists.txt 2009-05-20 18:45:29 UTC (rev 2999)
+++ branches/ggz/src/orxonox/CMakeLists.txt 2009-05-20 18:47:08 UTC (rev 3000)
@@ -19,13 +19,15 @@
SET_SOURCE_FILES(ORXONOX_SRC_FILES
CameraManager.cc
- GGZClient.cc
GraphicsEngine.cc
LevelManager.cc
Main.cc
PawnManager.cc
PlayerManager.cc
)
+IF(GGZMOD_FOUND)
+ ADD_SOURCE_FILES(ORXONOX_SRC_FILES GGZClient.cc)
+ENDIF(GGZMOD_FOUND)
ADD_SUBDIRECTORY(gamestates)
ADD_SUBDIRECTORY(gui)
ADD_SUBDIRECTORY(objects)
Modified: branches/ggz/src/orxonox/GGZClient.cc
===================================================================
--- branches/ggz/src/orxonox/GGZClient.cc 2009-05-20 18:45:29 UTC (rev 2999)
+++ branches/ggz/src/orxonox/GGZClient.cc 2009-05-20 18:47:08 UTC (rev 3000)
@@ -1,6 +1,7 @@
#include "GGZClient.h"
#include <cassert>
+#include <boost/bind.hpp>
namespace orxonox
{
@@ -12,21 +13,12 @@
assert(singletonRef_s == 0);
singletonRef_s = this;
- boost::asio::ip::tcp::socket::non_blocking_io non_blocking_io(true);
- ggzSocket.io_control(non_blocking_io);
- gameSocket.io_control(non_blocking_io);
-
- active = ggzmod_is_ggz_mode();
- if (active) {
- initGGZ();
- }
+ initGGZ();
}
GGZClient::~GGZClient()
{
- if (active) {
- deinitGGZ();
- }
+ deinitGGZ();
assert(singletonRef_s);
singletonRef_s = 0;
@@ -38,6 +30,11 @@
return *singletonRef_s;
}
+ bool GGZClient::isActive()
+ {
+ return ggzmod_is_ggz_mode();
+ }
+
void GGZClient::tick(const float /*dt*/)
{
boost::system::error_code ec;
@@ -60,8 +57,8 @@
/* TODO: Error */
}
/* TODO: Error */
- ggzSocket.assign(boost::asio::ip::tcp::v4(), fd);
- ggzSocket.async_read_some(boost::asio::null_buffers(), handleGGZ);
+ 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()
@@ -71,7 +68,7 @@
}
/* Got data from game server */
- void handleGame(const boost::system::error_code& /*e*/)
+ void GGZClient::handleGame(const boost::system::error_code& /*e*/)
{
/* TODO: read from gameSocket */
}
@@ -87,7 +84,7 @@
const void *data)
{
ggzmod_set_state(ggzmod, GGZMOD_STATE_PLAYING);
- gameSocket.assign(boost::asio::ip::tcp::v4(), *(int*)data);
- gameSocket.async_read_some(boost::asio::null_buffers(), handleGame);
+ 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-20 18:45:29 UTC (rev 2999)
+++ branches/ggz/src/orxonox/GGZClient.h 2009-05-20 18:47:08 UTC (rev 3000)
@@ -16,21 +16,21 @@
~GGZClient();
static GGZClient& getInstance();
+ static bool isActive();
virtual void tick(const float dt);
private:
static GGZClient* singletonRef_s;
- bool active;
GGZMod * ggzmod;
boost::asio::io_service io;
- boost::asio::ip::tcp::socket ggzSocket;
- boost::asio::ip::tcp::socket gameSocket;
+ boost::asio::local::stream_protocol::socket ggzSocket;
+ boost::asio::local::stream_protocol::socket gameSocket;
void initGGZ();
void deinitGGZ();
- void handleGame(const boost::system::error_code& e);
- void handleGGZ(const boost::system::error_code& e);
+ 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);
};
Modified: branches/ggz/src/orxonox/gamestates/GSClient.cc
===================================================================
--- branches/ggz/src/orxonox/gamestates/GSClient.cc 2009-05-20 18:45:29 UTC (rev 2999)
+++ branches/ggz/src/orxonox/gamestates/GSClient.cc 2009-05-20 18:47:08 UTC (rev 3000)
@@ -23,6 +23,7 @@
* Reto Grieder
* Co-authors:
* Fabian 'x3n' Landau
+ * Adrian Friedli
*
*/
@@ -52,6 +53,19 @@
{
Core::setIsClient(true);
+#ifdef HAS_GGZ
+ ggzClient = NULL;
+ if (GGZClient::isActive()) {
+ COUT(3) << "Initializing GGZ\n";
+ ggzClient = new GGZClient;
+ }
+ else {
+ COUT(3) << "Not using GGZ\n";
+ }
+#else /* HAS_GGZ */
+ COUT(3) << "GGZ support disabled\n";
+#endif /* HAS_GGZ */
+
this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
if(!client_->establishConnection())
@@ -68,6 +82,13 @@
client_->closeConnection();
+#ifdef HAS_GGZ
+ if (ggzClient)
+ {
+ delete ggzClient;
+ }
+#endif /* HAS_GGZ */
+
// destroy client
delete this->client_;
Modified: branches/ggz/src/orxonox/gamestates/GSClient.h
===================================================================
--- branches/ggz/src/orxonox/gamestates/GSClient.h 2009-05-20 18:45:29 UTC (rev 2999)
+++ branches/ggz/src/orxonox/gamestates/GSClient.h 2009-05-20 18:47:08 UTC (rev 3000)
@@ -22,7 +22,7 @@
* Author:
* Reto Grieder
* Co-authors:
- * ...
+ * Adrian Friedli
*
*/
@@ -33,6 +33,9 @@
#include "network/NetworkPrereqs.h"
#include "GSLevel.h"
#include "GSGraphics.h"
+#ifdef HAS_GGZ
+#include "GGZClient.h"
+#endif /* HAS_GGZ */
namespace orxonox
{
@@ -49,6 +52,10 @@
void ticked(const Clock& time);
Client* client_;
+#ifdef HAS_GGZ
+ GGZClient* ggzClient;
+#endif /* HAS_GGZ */
+
};
}
More information about the Orxonox-commit
mailing list