[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src client/Game.cpp common/const.h serve...
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src client/Game.cpp common/const.h serve... |
Date: |
Fri, 28 Feb 2003 07:41:02 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/02/28 07:40:55
Modified files:
src/client : Game.cpp
src/common : const.h
src/server : CaminoServer.cpp CaminoServer.h Player.cpp
ServerDialog.cpp ServerDialog.h
Log message:
- start server only when the server dialog is finished
Patches:
Index: camino/src/client/Game.cpp
diff -u camino/src/client/Game.cpp:1.22 camino/src/client/Game.cpp:1.23
--- camino/src/client/Game.cpp:1.22 Thu Feb 27 18:21:34 2003
+++ camino/src/client/Game.cpp Fri Feb 28 07:40:53 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Game.cpp,v 1.22 2003/02/27 23:21:34 pfremy Exp $
+** Version : $Id: Game.cpp,v 1.23 2003/02/28 12:40:53 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 15/01/2003
@@ -168,6 +168,7 @@
qDebug("Game - Connection with server closed!");
_state = StateNotConnected;
emit sig_connected( false );
+ displayServerMsg( "Connection closed!");
}
void Game::recvMsg( QString source, QString msg )
Index: camino/src/common/const.h
diff -u camino/src/common/const.h:1.1 camino/src/common/const.h:1.2
--- camino/src/common/const.h:1.1 Thu Feb 27 08:35:59 2003
+++ camino/src/common/const.h Fri Feb 28 07:40:54 2003
@@ -8,6 +8,9 @@
const int nbHorTiles = 14;
const int nbVerTiles = 10;
+const int nbTiles4players = 5;
+const int nbTiles2players = 6;
+
}
#endif // CONST_H
Index: camino/src/server/CaminoServer.cpp
diff -u camino/src/server/CaminoServer.cpp:1.13
camino/src/server/CaminoServer.cpp:1.14
--- camino/src/server/CaminoServer.cpp:1.13 Thu Feb 27 14:34:39 2003
+++ camino/src/server/CaminoServer.cpp Fri Feb 28 07:40:54 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: CaminoServer.cpp,v 1.13 2003/02/27 19:34:39 pfremy Exp $
+** Version : $Id: CaminoServer.cpp,v 1.14 2003/02/28 12:40:54 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 19/01/2003
@@ -29,6 +29,7 @@
#include <qsignalmapper.h>
// application specific include files
+#include "common/const.h"
#include "common/log.h"
#include "common/TileStack.h"
#include "server/Player.h"
@@ -42,6 +43,7 @@
_playerNb = playerNb;
_state = WaitingForConnection;
_activePlayer = 0L;
+ _teamConfiguration = 0;
}
void CaminoServer::newConnection( int numSocket )
@@ -82,15 +84,14 @@
return true;
}
-void CaminoServer::setTeamConfiguration( int /* teamConfiguration */ )
+void CaminoServer::setTeamConfiguration( int teamConfiguration )
{
- // sort players accorging to team configuration
- beginParty();
+ _teamConfiguration = teamConfiguration;
}
void CaminoServer::beginParty()
{
- if (_state != SelectTeam && _state != WaitingForConnection ) {
+ if (_state != ReadyToStart ) {
QString s = QString("CaminoServer::beginParty - unexpected
state : %1").arg(_state);
qWarning("%s", s.latin1() );
serverBroadcastMsg( DebugMsg, s );
@@ -101,6 +102,8 @@
serverBroadcastMsg( InfoMsg, "Begin Party" );
_state = BeginParty;
+ // sort players accorging to team configuration
+ //
_tileStack->init();
distributeTiles();
@@ -130,10 +133,12 @@
void CaminoServer::distributeTiles()
{
qDebug( "CaminoServer::distributeTiles() " );
- int tilesPerPlayer = 6;
+ int tilesPerPlayer = 0;
- if ( _playerNb > 2 ) {
- tilesPerPlayer--;
+ if ( _playerNb == 2 ) {
+ tilesPerPlayer = Camino::nbTiles2players;
+ } else {
+ tilesPerPlayer = Camino::nbTiles4players;
}
for ( int i=0; i < tilesPerPlayer; i++ ) {
Index: camino/src/server/CaminoServer.h
diff -u camino/src/server/CaminoServer.h:1.10
camino/src/server/CaminoServer.h:1.11
--- camino/src/server/CaminoServer.h:1.10 Thu Feb 27 14:34:39 2003
+++ camino/src/server/CaminoServer.h Fri Feb 28 07:40:54 2003
@@ -5,7 +5,7 @@
** CaminoServer.h
** Server for the game
**
-** Version : $Id: CaminoServer.h,v 1.10 2003/02/27 19:34:39 pfremy Exp $
+** Version : $Id: CaminoServer.h,v 1.11 2003/02/28 12:40:54 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 19/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -63,7 +63,7 @@
enum ServerState {
WaitingForConnection,
- SelectTeam,
+ ReadyToStart,
BeginParty,
PlayGame,
UndoRequested,
@@ -79,8 +79,9 @@
void broadcastMsg( NetMsgSubtype msgLevel, QString source, QString msg
);
void serverBroadcastMsg( NetMsgSubtype msgLevel, QString msg ) {
broadcastMsg( msgLevel, "Server", msg); }
void setTeamConfiguration( int teamConfiguration );
- void beginParty();
+ void readyToStart();
+ void beginParty();
void distributeTiles();
void sendDistributedTiles();
void activateNextPlayer();
@@ -90,13 +91,14 @@
void sig_endConnection( QString name );
void sig_playerConnected( QString hostName, QString playerName );
- void sig_selectTeam();
+ void sig_readyToStart();
void sig_msg( NetMsgSubtype level, QString source, QString msg );
protected:
QPtrList<Player> _playerList;
TileStack * _tileStack;
int _playerNb;
+ int _teamConfiguration;
ServerState _state;
Player * _activePlayer;
Index: camino/src/server/Player.cpp
diff -u camino/src/server/Player.cpp:1.10 camino/src/server/Player.cpp:1.11
--- camino/src/server/Player.cpp:1.10 Thu Feb 27 16:44:56 2003
+++ camino/src/server/Player.cpp Fri Feb 28 07:40:54 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Player.cpp,v 1.10 2003/02/27 21:44:56 pfremy Exp $
+** Version : $Id: Player.cpp,v 1.11 2003/02/28 12:40:54 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -43,11 +43,9 @@
void Player::slotDecode()
{
-// qDebug("Player - slotDecode()");
- // notify server which socket is speaking
- qDebug( "bytes available : %ld", _socket->bytesAvailable() );
while( _socket->bytesAvailable() ) {
MsgDecoder::slotDecode();
+ // qDebug( "bytes available : %ld", _socket->bytesAvailable() );
}
}
@@ -72,13 +70,9 @@
setPlayerName( playerName );
if ( _server->_playerList.count() == (uint) _server->_playerNb ) {
- if ( _server->_playerNb > 2) {
- _server->_state = CaminoServer::SelectTeam;
- emit _server->sig_selectTeam();
- } else {
- emit _server->sig_selectTeam(); // normally not
necessary in two players mode
- _server->beginParty();
- }
+ // normally not necessary in two players mode
+ emit _server->sig_readyToStart();
+ _server->_state = CaminoServer::ReadyToStart;
}
}
Index: camino/src/server/ServerDialog.cpp
diff -u camino/src/server/ServerDialog.cpp:1.12
camino/src/server/ServerDialog.cpp:1.13
--- camino/src/server/ServerDialog.cpp:1.12 Fri Feb 28 07:08:08 2003
+++ camino/src/server/ServerDialog.cpp Fri Feb 28 07:40:54 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: ServerDialog.cpp,v 1.12 2003/02/28 12:08:08 pfremy Exp $
+** Version : $Id: ServerDialog.cpp,v 1.13 2003/02/28 12:40:54 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -82,7 +82,7 @@
}
}
-void ServerDialog::slot_selectTeam()
+void ServerDialog::slot_readyToStart()
{
Q_ASSERT( _playerList->childCount() >= _nb);
if ( _nb == 2) {
@@ -134,7 +134,7 @@
connect( _server, SIGNAL( sig_playerConnected(QString,QString)),
SLOT( slot_playerConnected(QString,QString)) );
- connect ( _server, SIGNAL( sig_selectTeam() ), SLOT( slot_selectTeam()
) );
+ connect ( _server, SIGNAL( sig_readyToStart() ), SLOT(
slot_readyToStart() ) );
connect( _server, SIGNAL( sig_msg( NetMsgSubtype, QString, QString )
),
_serverWidget, SLOT( slot_appendMsg( NetMsgSubtype,
QString, QString ) ) );
}
@@ -150,6 +150,8 @@
if (_nb != 2) {
_server->setTeamConfiguration( _team );
}
+
+ _server->beginParty();
emit sig_serverStarted( _server, _serverWidget );
ServerDialogUI::accept();
Index: camino/src/server/ServerDialog.h
diff -u camino/src/server/ServerDialog.h:1.9
camino/src/server/ServerDialog.h:1.10
--- camino/src/server/ServerDialog.h:1.9 Thu Feb 27 17:58:39 2003
+++ camino/src/server/ServerDialog.h Fri Feb 28 07:40:54 2003
@@ -5,7 +5,7 @@
** ServerDialog.h
** Main dialog of the server
**
-** Version : $Id: ServerDialog.h,v 1.9 2003/02/27 22:58:39 pfremy Exp $
+** Version : $Id: ServerDialog.h,v 1.10 2003/02/28 12:40:54 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 15/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -63,7 +63,7 @@
void slot_team3();
void slot_pageSelected( const QString & title );
- void slot_selectTeam(); // advance to select team
+ void slot_readyToStart(); // advance to select team
signals:
void sig_quit();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Camino-devel] camino/src client/Game.cpp common/const.h serve...,
Philippe Fremy <=