camino-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Camino-devel] camino/src/client ClientEngine.cpp ClientEngine...


From: Pascal Audoux
Subject: [Camino-devel] camino/src/client ClientEngine.cpp ClientEngine...
Date: Tue, 18 Feb 2003 17:18:28 -0500

CVSROOT:        /cvsroot/camino
Module name:    camino
Changes by:     Pascal Audoux <address@hidden>  03/02/18 17:18:27

Modified files:
        src/client     : ClientEngine.cpp ClientEngine.h Game.cpp Game.h 

Log message:
        some management of interaction between Game and ClientEngine (recvTile, 
sendUndo, sendMessage)

Patches:
Index: camino/src/client/ClientEngine.cpp
diff -u camino/src/client/ClientEngine.cpp:1.12 
camino/src/client/ClientEngine.cpp:1.13
--- camino/src/client/ClientEngine.cpp:1.12     Tue Feb 18 16:05:12 2003
+++ camino/src/client/ClientEngine.cpp  Tue Feb 18 17:18:27 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: ClientEngine.cpp,v 1.12 2003/02/18 21:05:12 pfremy Exp $
+** Version : $Id: ClientEngine.cpp,v 1.13 2003/02/18 22:18:27 Audoux Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 14/01/2003
@@ -27,11 +27,13 @@
 #include <qsocket.h>
 // application specific include files
 #include "ClientEngine.h"
+#include "Game.h"
 #include "common/MsgCoder.h"
 
 
 /** add comments here */
-ClientEngine::ClientEngine()
+ClientEngine::ClientEngine( Game * game )
+: _game( game )
 {
        _socket = new QSocket( this );
        _state = StateNotConnected;
@@ -42,6 +44,11 @@
        connect( _socket, SIGNAL( readyRead() ), SLOT( slotDecode() ) );
 }
 
+ClientEngine::~ClientEngine()
+{
+
+}
+
 bool ClientEngine::isConnected()
 {
        return( _state != StateNotConnected );
@@ -97,18 +104,19 @@
 
        qDebug( "Client - %s from %s : %s", typeString.latin1(), 
source.latin1(), msg.latin1() );
        QString text = source + " : " + msg;
-       emit sig_message( text );
+       //emit sig_message( text );
+       _game->displayServerMessage( text );
 }
 
 void ClientEngine::sendMessage( NetMsgSubtype msgLevel, const QString & msg )
 {
-       sendMsg( msgLevel, _playerName, msg );
+       MsgCoder::sendMsg( msgLevel, _playerName, msg );
 }
 
 void ClientEngine::sendUndo()
 {
        if( _state == StatePlay ) {
-               sendUndo();
+               MsgCoder::sendUndoRequest();
                _state = StateUndoProcessing;
        }
 }
@@ -127,4 +135,5 @@
 void ClientEngine::recvTile( Tile::TileType tile )
 {
        qDebug( "ClientEngine::recvTile - %d", ( int )tile );
+       //_game->addTile( tile, rotation );
 }
Index: camino/src/client/ClientEngine.h
diff -u camino/src/client/ClientEngine.h:1.10 
camino/src/client/ClientEngine.h:1.11
--- camino/src/client/ClientEngine.h:1.10       Tue Feb 18 16:05:12 2003
+++ camino/src/client/ClientEngine.h    Tue Feb 18 17:18:27 2003
@@ -5,7 +5,7 @@
 ** ClientEngine.h
 ** The intelligence of the client is here
 **
-** Version : $Id: ClientEngine.h,v 1.10 2003/02/18 21:05:12 pfremy Exp $
+** Version : $Id: ClientEngine.h,v 1.11 2003/02/18 22:18:27 Audoux Exp $
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 14/01/2003
 ** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -35,13 +35,15 @@
 // application specific include files
 #include "common/MsgDecoder.h"
 #include "common/MsgCoder.h"
- 
- 
+
+class QSocket;
+class Game;
+
 /*              ------------------------------
  *                         ClientEngine
  *              ------------------------------ */
 
-class QSocket;
+
 
 /** comment for the class */
 class ClientEngine : public MsgDecoder, public MsgCoder
@@ -50,7 +52,9 @@
 
 public:
        /** Constructor */
-       ClientEngine();
+       ClientEngine( Game * game );
+
+       virtual ~ClientEngine();
 
        void connectToServer( const QString & serverName, int port, const 
QString & playerName );
 
@@ -88,6 +92,7 @@
        } _state;
        QSocket * _socket;
        QString _playerName;
+       Game * _game;
 
 };
  
Index: camino/src/client/Game.cpp
diff -u camino/src/client/Game.cpp:1.14 camino/src/client/Game.cpp:1.15
--- camino/src/client/Game.cpp:1.14     Tue Feb 18 16:05:12 2003
+++ camino/src/client/Game.cpp  Tue Feb 18 17:18:27 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: Game.cpp,v 1.14 2003/02/18 21:05:12 pfremy Exp $
+** Version : $Id: Game.cpp,v 1.15 2003/02/18 22:18:27 Audoux Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 15/01/2003
@@ -42,7 +42,8 @@
 Game::Game( QWidget * parent , const char * name )
   : QWidget( parent, name, QWidget::WStyle_Customize | 
QWidget::WStyle_DialogBorder )
 {
-       _engine = new ClientEngine();
+       _engine = new ClientEngine( this );
+
        _board = new BoardCanvas( this );
 
        QVBoxLayout * layout = new QVBoxLayout( this );
@@ -62,10 +63,8 @@
        _actions = new ActionList( hbox );
        _chat = new ChatWidget( vbox );
 
-       _board->addTile( 1, 1 );
-
        connect( _chat, SIGNAL( sig_message( const QString & ) ), SLOT( 
slot_chatMessage( const QString & ) ) );
-       connect( _engine, SIGNAL( sig_message( const QString & ) ), SLOT( 
slot_serverMessage( const QString & ) ) );
+       //connect( _engine, SIGNAL( sig_message( const QString & ) ), SLOT( 
slot_serverMessage( const QString & ) ) );
        connect( _engine, SIGNAL( sig_connected( bool ) ), SIGNAL( 
sig_connected( bool ) ) );
        connect( _engine, SIGNAL( sig_connected( bool ) ), SLOT( 
slot_clientConnected( bool ) ) );
 
@@ -108,9 +107,14 @@
         }
 }
 
-void Game::slot_serverMessage( const QString & msg )
+void Game::displayServerMessage( const QString & msg )
 {
        _chat->newMessage( msg );
+}
+
+void Game::addTile( Tile * tile )
+{
+       _board->addTile( tile );
 }
 
 void Game::slot_tile( int /* tile */ )
Index: camino/src/client/Game.h
diff -u camino/src/client/Game.h:1.12 camino/src/client/Game.h:1.13
--- camino/src/client/Game.h:1.12       Tue Feb 18 16:05:12 2003
+++ camino/src/client/Game.h    Tue Feb 18 17:18:27 2003
@@ -5,7 +5,7 @@
 ** Game.h
 ** Main widget of the game
 **
-** Version : $Id: Game.h,v 1.12 2003/02/18 21:05:12 pfremy Exp $
+** Version : $Id: Game.h,v 1.13 2003/02/18 22:18:27 Audoux Exp $
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 15/01/2003
 ** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -62,10 +62,14 @@
 
        void reupdate();
 
+       void displayServerMessage( const QString & msg );
+
+       void addTile( Tile * tile );
+
 public slots:
        void slot_chatMessage( const QString & msg );
 
-       void slot_serverMessage( const QString & msg );
+       //void slot_serverMessage( const QString & msg );
 
        void slot_tile( int tile );
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]