Changeset 3000 for code/branches/ggz/src/orxonox
- Timestamp:
- May 20, 2009, 8:47:08 PM (16 years ago)
- Location:
- code/branches/ggz/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ggz/src/orxonox/CMakeLists.txt
r2889 r3000 20 20 SET_SOURCE_FILES(ORXONOX_SRC_FILES 21 21 CameraManager.cc 22 GGZClient.cc23 22 GraphicsEngine.cc 24 23 LevelManager.cc … … 27 26 PlayerManager.cc 28 27 ) 28 IF(GGZMOD_FOUND) 29 ADD_SOURCE_FILES(ORXONOX_SRC_FILES GGZClient.cc) 30 ENDIF(GGZMOD_FOUND) 29 31 ADD_SUBDIRECTORY(gamestates) 30 32 ADD_SUBDIRECTORY(gui) -
code/branches/ggz/src/orxonox/GGZClient.cc
r2997 r3000 2 2 3 3 #include <cassert> 4 #include <boost/bind.hpp> 4 5 5 6 namespace orxonox … … 13 14 singletonRef_s = this; 14 15 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(); 23 17 } 24 18 25 19 GGZClient::~GGZClient() 26 20 { 27 if (active) { 28 deinitGGZ(); 29 } 21 deinitGGZ(); 30 22 31 23 assert(singletonRef_s); … … 37 29 assert(singletonRef_s); 38 30 return *singletonRef_s; 31 } 32 33 bool GGZClient::isActive() 34 { 35 return ggzmod_is_ggz_mode(); 39 36 } 40 37 … … 61 58 } 62 59 /* 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)); 65 62 } 66 63 … … 72 69 73 70 /* Got data from game server */ 74 void handleGame(const boost::system::error_code& /*e*/)71 void GGZClient::handleGame(const boost::system::error_code& /*e*/) 75 72 { 76 73 /* TODO: read from gameSocket */ … … 88 85 { 89 86 ggzmod_set_state(ggzmod, GGZMOD_STATE_PLAYING); 90 g ameSocket.assign(boost::asio::ip::tcp::v4(), *(int*)data);91 g ameSocket.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)); 92 89 } 93 90 } -
code/branches/ggz/src/orxonox/GGZClient.h
r2997 r3000 17 17 18 18 static GGZClient& getInstance(); 19 static bool isActive(); 19 20 virtual void tick(const float dt); 20 21 … … 22 23 static GGZClient* singletonRef_s; 23 24 24 bool active;25 25 GGZMod * ggzmod; 26 26 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; 29 29 30 30 void initGGZ(); 31 31 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); 34 34 static void handleGGZModServer(GGZMod * ggzmod, GGZModEvent e, 35 35 const void *data); -
code/branches/ggz/src/orxonox/gamestates/GSClient.cc
r2171 r3000 24 24 * Co-authors: 25 25 * Fabian 'x3n' Landau 26 * Adrian Friedli 26 27 * 27 28 */ … … 53 54 Core::setIsClient(true); 54 55 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 55 69 this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port")); 56 70 … … 69 83 client_->closeConnection(); 70 84 85 #ifdef HAS_GGZ 86 if (ggzClient) 87 { 88 delete ggzClient; 89 } 90 #endif /* HAS_GGZ */ 91 71 92 // destroy client 72 93 delete this->client_; -
code/branches/ggz/src/orxonox/gamestates/GSClient.h
r2171 r3000 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Adrian Friedli 26 26 * 27 27 */ … … 34 34 #include "GSLevel.h" 35 35 #include "GSGraphics.h" 36 #ifdef HAS_GGZ 37 #include "GGZClient.h" 38 #endif /* HAS_GGZ */ 36 39 37 40 namespace orxonox … … 50 53 51 54 Client* client_; 55 #ifdef HAS_GGZ 56 GGZClient* ggzClient; 57 #endif /* HAS_GGZ */ 58 52 59 }; 53 60 }
Note: See TracChangeset
for help on using the changeset viewer.