camino-devel
[Top][All Lists]
Advanced

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

[Camino-devel] camino/src/server CaminoServer.cpp CaminoServer...


From: Philippe Fremy
Subject: [Camino-devel] camino/src/server CaminoServer.cpp CaminoServer...
Date: Sun, 02 Mar 2003 19:12:04 -0500

CVSROOT:        /cvsroot/camino
Module name:    camino
Changes by:     Philippe Fremy <address@hidden> 03/03/02 19:12:04

Modified files:
        src/server     : CaminoServer.cpp CaminoServer.h 
                         ServerDialog.cpp 

Log message:
        use team selection from dialog to make the teams

Patches:
Index: camino/src/server/CaminoServer.cpp
diff -u camino/src/server/CaminoServer.cpp:1.17 
camino/src/server/CaminoServer.cpp:1.18
--- camino/src/server/CaminoServer.cpp:1.17     Sun Mar  2 18:45:38 2003
+++ camino/src/server/CaminoServer.cpp  Sun Mar  2 19:12:04 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: CaminoServer.cpp,v 1.17 2003/03/02 23:45:38 pfremy Exp $
+** Version : $Id: CaminoServer.cpp,v 1.18 2003/03/03 00:12:04 pfremy Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 19/01/2003
@@ -104,14 +104,46 @@
        serverBroadcastMsg( InfoMsg, "Begin Party" );
        _state = BeginParty;
 
-       // sort players according to team configuration
-       //
+       sortPlayers();
        _tileStack->init();
-
        distributeTiles();
        activateNextPlayer();
-       
        _state = PlayGame;
+}
+
+
+void CaminoServer::sortPlayers()
+{
+       if (_playerNb == 2) return;
+
+       Player *p2, *p3, *p4;
+       p4 = _playerList.take( 3 );
+       p3 = _playerList.take( 2 );
+       p2 = _playerList.take( 1 );
+
+       if (_teamConfiguration == 1) {
+               _playerList.append( p3 );
+               _playerList.append( p2 );
+               _playerList.append( p4 );
+               return;
+       }
+
+       if (_teamConfiguration == 2) {
+               _playerList.append( p2 );
+               _playerList.append( p3 );
+               _playerList.append( p4 );
+               return;
+       }
+
+       if (_teamConfiguration == 3) {
+               _playerList.append( p2 );
+               _playerList.append( p4 );
+               _playerList.append( p3 );
+               return;
+       }
+
+       qDebug("CaminoServer::sortPlayers - unknown team configuration : %d", 
+       _teamConfiguration );
 }
 
 void CaminoServer::activateNextPlayer()
Index: camino/src/server/CaminoServer.h
diff -u camino/src/server/CaminoServer.h:1.13 
camino/src/server/CaminoServer.h:1.14
--- camino/src/server/CaminoServer.h:1.13       Sun Mar  2 11:31:28 2003
+++ camino/src/server/CaminoServer.h    Sun Mar  2 19:12:04 2003
@@ -5,7 +5,7 @@
 ** CaminoServer.h
 ** Server for the game
 **
-** Version : $Id: CaminoServer.h,v 1.13 2003/03/02 16:31:28 pfremy Exp $
+** Version : $Id: CaminoServer.h,v 1.14 2003/03/03 00:12:04 pfremy Exp $
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 19/01/2003
 ** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -82,6 +82,7 @@
 
        void readyToStart();
        void beginParty();
+       void sortPlayers();
        void distributeTiles();
        void sendDistributedTiles();
        void activateNextPlayer();
Index: camino/src/server/ServerDialog.cpp
diff -u camino/src/server/ServerDialog.cpp:1.13 
camino/src/server/ServerDialog.cpp:1.14
--- camino/src/server/ServerDialog.cpp:1.13     Fri Feb 28 07:40:54 2003
+++ camino/src/server/ServerDialog.cpp  Sun Mar  2 19:12:04 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: ServerDialog.cpp,v 1.13 2003/02/28 12:40:54 pfremy Exp $
+** Version : $Id: ServerDialog.cpp,v 1.14 2003/03/03 00:12:04 pfremy Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 14/01/2003
@@ -42,6 +42,8 @@
 ServerDialog::ServerDialog( QWidget * parent, const char * name )
 :ServerDialogUI( parent, name )
 {
+       _playerList->setSorting( -1 );
+
        _team1->toggle();
        _team2->toggle();
        _team3->toggle();
@@ -141,8 +143,10 @@
 
 void ServerDialog::slot_playerConnected( QString hostName, QString playerName )
 {
-       qDebug("ServerDialog - slotPlayerConnected!");
-       new QListViewItem( _playerList, playerName, hostName );
+       QListViewItem * lastItem = _playerList->lastItem();
+       qDebug("ServerDialog - slotPlayerConnected - %s!", hostName.latin1());
+       qDebug("ServerDialog - lastItem - %s!", lastItem ? 
lastItem->text(1).latin1() : "<nothing>" );
+       new QListViewItem( _playerList, lastItem, playerName, hostName );
 }
 
 void ServerDialog::accept()




reply via email to

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