netpanzer-cvs
[Top][All Lists]
Advanced

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

[netPanzer-CVS] netpanzer/src ChangeLog Lib/Particles/FlamePart...


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer/src ChangeLog Lib/Particles/FlamePart...
Date: Mon, 08 Sep 2003 17:25:09 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/09/08 17:25:09

Modified files:
        src            : ChangeLog 
        src/Lib/Particles: FlameParticle2D.cpp FlashParticle2D.cpp 
                           ParticleInterface.cpp 
                           TemplateExplosionSystem.cpp 
                           TrajectoryParticle2D.cpp 
        src/NetPanzer/Classes/Network: ClientConnectDaemon.cpp 
                                       NetworkClient.cpp 
        src/NetPanzer/Interfaces: GameManager.cpp 
        src/NetPanzer/Interfaces/unix: NetworkClientUnix.cpp 
        src/NetPanzer/Views/MainMenu: MenuTemplateView.cpp 
        src/NetPanzer/Views/MainMenu/Multi: GetSessionView.cpp 
                                            IPAddressView.cpp 
        src/UILib/Network: Client.cpp Client.hpp ClientList.cpp 
                           ClientList.hpp ClientSocket.cpp 
                           ClientSocket.hpp ServerSocket.cpp 
                           ServerSocket.hpp 
        src/UILib/SDL  : SDLDraw.cpp 

Log message:
        -lots of small fixes in the network code, a local connection works now 
but
        crashs relatively soon after moving a bit around...
        -applied a patch from Raphael Bosshard which fixes a few warnings

Patches:
Index: netpanzer/src/ChangeLog
diff -u netpanzer/src/ChangeLog:1.11 netpanzer/src/ChangeLog:1.12
--- netpanzer/src/ChangeLog:1.11        Mon Sep  8 12:46:22 2003
+++ netpanzer/src/ChangeLog     Mon Sep  8 17:25:08 2003
@@ -9,6 +9,8 @@
 -added possibility to switch windows/fullscreen mode on ALT+ENTER
 -fixed some smaller bugs in Splitpath and FileUtil
 -added an fps counter to the info window
+-lots of small fixes in the network code
+-applied a patch from Raphael Bosshard which fixes a few warnings
 
 7-Sep-2003 by Matze Braun
 -removed NetMessageLog class (because it only contained shit ;-)
Index: netpanzer/src/Lib/Particles/FlameParticle2D.cpp
diff -u netpanzer/src/Lib/Particles/FlameParticle2D.cpp:1.5 
netpanzer/src/Lib/Particles/FlameParticle2D.cpp:1.6
--- netpanzer/src/Lib/Particles/FlameParticle2D.cpp:1.5 Sun Sep  7 16:49:02 2003
+++ netpanzer/src/Lib/Particles/FlameParticle2D.cpp     Mon Sep  8 17:25:08 2003
@@ -94,8 +94,8 @@
 
                float percent = float(i) / float(maxLevel);
 
-               newSize.x = float(tempSurface.getPixX()) * percent;
-               newSize.y = float(tempSurface.getPixY()) * percent;
+               newSize.x = int(float(tempSurface.getPixX()) * percent);
+               newSize.y = int(float(tempSurface.getPixY()) * percent);
 
                tempSurface.scale(newSize);
                tempSurface.setFPS(explosionFPS);
@@ -116,8 +116,8 @@
 
                float percent = float(i) / float(maxLevel);
 
-               newSize.x = float(tempSurface.getPixX()) * percent;
-               newSize.y = float(tempSurface.getPixY()) * percent;
+               newSize.x = int(float(tempSurface.getPixX()) * percent);
+               newSize.y = int(float(tempSurface.getPixY()) * percent);
 
                tempSurface.scale(newSize);
                tempSurface.setFPS(explosionFPS);
@@ -180,7 +180,7 @@
                return;
        }
 
-       packedSurface.setAttrib(PointXYi(pos.x, pos.z), layer);
+       packedSurface.setAttrib(PointXYi((int)pos.x, (int)pos.z), layer);
        sorter.addSprite(&packedSurface);
 
 } // end FlameParticle2D::draw
Index: netpanzer/src/Lib/Particles/FlashParticle2D.cpp
diff -u netpanzer/src/Lib/Particles/FlashParticle2D.cpp:1.5 
netpanzer/src/Lib/Particles/FlashParticle2D.cpp:1.6
--- netpanzer/src/Lib/Particles/FlashParticle2D.cpp:1.5 Sun Sep  7 16:49:02 2003
+++ netpanzer/src/Lib/Particles/FlashParticle2D.cpp     Mon Sep  8 17:25:08 2003
@@ -80,11 +80,11 @@
        const float maxFlashSize = 200.0f;
        const float flashCount   =  20.0f;
 
-       outputSurface.create(surface.getPixX(), surface.getPixY(), 
surface.getPixX(), flashCount);
+       outputSurface.create(surface.getPixX(), surface.getPixY(), 
surface.getPixX(), int(flashCount));
 
        int n = 0;
 
-       for (int i = minFlashSize; i < maxFlashSize - minFlashSize; i += 
(maxFlashSize - minFlashSize) / flashCount)
+       for (int i = (int)minFlashSize; i < maxFlashSize - minFlashSize; i += 
int((maxFlashSize - minFlashSize) / flashCount))
        {
                // Set the output frame.
                outputSurface.setFrame(n++);
@@ -92,8 +92,8 @@
 
                // Copy and scale the surface.
                scaledSurface.copy(surface);
-               float x = float(surface.getPixX()) * (float(i) / maxFlashSize);
-               float y = float(surface.getPixY()) * (float(i) / maxFlashSize);
+               int x = int(float(surface.getPixX()) * (float(i) / 
maxFlashSize));
+               int y = int(float(surface.getPixY()) * (float(i) / 
maxFlashSize));
                scaledSurface.scale(x, y);
 
                iXY dest((surface.getPix() - scaledSurface.getPix()) / 2);
@@ -133,7 +133,7 @@
 
        packedSurface.setFrame(frame);
 
-       packedSurface.setAttrib(PointXYi(pos.x, pos.z), layer);
+       packedSurface.setAttrib(PointXYi((int)pos.x, (int)pos.z), layer);
        sorter.addSprite(&packedSurface);
 
        // Since we only want a single frame of the flash, kill it after it is 
done.
Index: netpanzer/src/Lib/Particles/ParticleInterface.cpp
diff -u netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.4 
netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.5
--- netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.4       Mon Sep  8 
08:12:18 2003
+++ netpanzer/src/Lib/Particles/ParticleInterface.cpp   Mon Sep  8 17:25:08 2003
@@ -482,9 +482,9 @@
 
        e.percentScaleMin    = 0.8f;
        e.percentScaleRand   = 0.6f;
-       e.speedSmall         = 400 * hitPointScale;
-       e.speedMedium        = 250 * hitPointScale;
-       e.speedLarge         = 150 * hitPointScale;
+       e.speedSmall         = int(400 * hitPointScale);
+       e.speedMedium        = int(250 * hitPointScale);
+       e.speedLarge         = int(150 * hitPointScale);
        e.percentCountSmall  = 0.4f;
        e.percentCountMedium = 0.3f;
        e.percentCountLarge  = 0.3f;
@@ -496,7 +496,7 @@
        e.flashMinScale      = 0.6f * hitPointScale;
        e.flashRandScale     = 0.4f * hitPointScale;
        e.flashLifetime      = 0.5f;
-       e.flashCount         = 3 * 
float(unitParticleInfo[unitState.unit_type].minBounds.getArea()) / 
float(unitBodyMaxArea);
+       e.flashCount         = int( 3 * 
float(unitParticleInfo[unitState.unit_type].minBounds.getArea()) / 
float(unitBodyMaxArea));
        e.flashBounds        = unitParticleInfo[unitState.unit_type].minBounds;
 
        int randTrajectoryAngleMin = rand() % 3;
@@ -621,7 +621,7 @@
        float randomness = 1.0f; //Particle2D::getScale(0.8f, 0.4f);
        float frameRateAdjustment = getFrameRateAdjustment();
 
-       e.particleCount = 5 * (frameRateAdjustment * 
float(unitAttackFactorTable[unitType]) * randomness);
+       e.particleCount = int(5 * (frameRateAdjustment * 
float(unitAttackFactorTable[unitType]) * randomness));
 
        if (gDrawExplosionParticleCount)
        {
@@ -643,9 +643,9 @@
 
        e.percentScaleMin    = 0.8f;
        e.percentScaleRand   = 0.4f;
-       e.speedSmall         = 400 * attackScale;
-       e.speedMedium        = 250 * attackScale;
-       e.speedLarge         = 150 * attackScale;
+       e.speedSmall         = int(400 * attackScale);
+       e.speedMedium        = int(250 * attackScale);
+       e.speedLarge         = int(150 * attackScale);
        e.percentCountSmall  = 0.5f;
        e.percentCountMedium = 0.3f;
        e.percentCountLarge  = 0.2f;
@@ -682,8 +682,8 @@
        {
                UnitProfile *p = UnitProfileInterface::getUnitProfile(i);
                
-               unitHitPointTable[i]     = sqrt(p->hit_points);
-               unitAttackFactorTable[i] = sqrt(p->attack_factor * 2);
+               unitHitPointTable[i]     = int(sqrt(p->hit_points));
+               unitAttackFactorTable[i] = int(sqrt(p->attack_factor * 2));
        }
 }
 
@@ -703,7 +703,7 @@
 //--------------------------------------------------------------------------
 void ParticleInterface::addMissleFlightPuff(const iXY &worldPos, const fXY 
&direction, float &curWait, float &totalWait, BYTE unitType)
 {
-       iXY thrustOffset(-10.0f * direction.x, -10.0f * direction.y);
+       iXY thrustOffset(int(-10.0f * direction.x), int(-10.0f * direction.y));
        fXYZ loc(worldPos.x + thrustOffset.x, 0, worldPos.y + thrustOffset.y);
 
        curWait += TimerInterface::getTimeSlice();
Index: netpanzer/src/Lib/Particles/TemplateExplosionSystem.cpp
diff -u netpanzer/src/Lib/Particles/TemplateExplosionSystem.cpp:1.3 
netpanzer/src/Lib/Particles/TemplateExplosionSystem.cpp:1.4
--- netpanzer/src/Lib/Particles/TemplateExplosionSystem.cpp:1.3 Fri Sep  5 
22:01:18 2003
+++ netpanzer/src/Lib/Particles/TemplateExplosionSystem.cpp     Mon Sep  8 
17:25:08 2003
@@ -57,7 +57,7 @@
        int halfBoundsY = bounds.getSizeY() / 2;
 
        // Add a crater on the ground if it is a logical location.
-       int pixMovementValue = TileInterface::getWorldPixMovementValue(pos.x, 
pos.z);
+       int pixMovementValue = 
TileInterface::getWorldPixMovementValue(int(pos.x), int(pos.z));
 
        // Check for water or impassible.
        if (pixMovementValue != 5 &&
@@ -84,7 +84,7 @@
                        // Since this is a water explosion and only particles 
are getting thrown,
                        // add some more particles.
                        canHaveSmoke  = 0;
-                       particleCount = e.particleCount * 1.7f;
+                       particleCount = int(e.particleCount * 1.7f);
 
                } else 
                {
@@ -155,7 +155,7 @@
                offset.z = pos.z - (rand() % bounds.getSizeY()) + halfBoundsY;
 
                new ChunkTrajectoryParticle2D(  offset,
-                                                                               
maxSpeed,
+                                                                               
int(maxSpeed),
                                                                                
scaleMin,
                                                                                
scaleRand,
                                                                                
waitMin,
@@ -181,7 +181,7 @@
                offset.z = pos.z - (rand() % bounds.getSizeY()) + halfBoundsY;
 
                new ChunkTrajectoryParticle2D(  pos,
-                                                                               
maxSpeed,
+                                                                               
int(maxSpeed),
                                                                                
scaleMin,
                                                                                
scaleRand,
                                                                                
waitMin,
@@ -208,7 +208,7 @@
 
 
                new ChunkTrajectoryParticle2D(  pos,
-                                                                               
maxSpeed,
+                                                                               
int(maxSpeed),
                                                                                
scaleMin,
                                                                                
scaleRand,
                                                                                
waitMin,
Index: netpanzer/src/Lib/Particles/TrajectoryParticle2D.cpp
diff -u netpanzer/src/Lib/Particles/TrajectoryParticle2D.cpp:1.3 
netpanzer/src/Lib/Particles/TrajectoryParticle2D.cpp:1.4
--- netpanzer/src/Lib/Particles/TrajectoryParticle2D.cpp:1.3    Fri Sep  5 
22:01:18 2003
+++ netpanzer/src/Lib/Particles/TrajectoryParticle2D.cpp        Mon Sep  8 
17:25:08 2003
@@ -36,7 +36,7 @@
        
        TrajectoryParticle2D::dieAtMidFlight = dieAtMidFlight;
        
-       lifetime = (float(initialVelocity * Math::getSin(trajectoryAngle)) / 
Physics::getGravity()) * 2.0f;
+       lifetime = (float(initialVelocity * Math::getSin(int(trajectoryAngle))) 
/ Physics::getGravity()) * 2.0f;
        
        if (dieAtMidFlight)
        {
@@ -62,7 +62,7 @@
 void TrajectoryParticle2D::sim()
 {
        // Get the particle horizontal position.
-       float dx = Physics::getHorizontalPosition(initialVelocity, 
trajectoryAngle, age);
+       float dx = Physics::getHorizontalPosition(initialVelocity, 
int(trajectoryAngle), age);
 
        //pos += velocity;
 
@@ -71,7 +71,7 @@
        pos.x = initialPos.x + dx * direction.x;
        pos.z = initialPos.z + dx * direction.z;
 
-       pos.y = Physics::getVerticalPosition(initialVelocity, trajectoryAngle, 
age);
+       pos.y = Physics::getVerticalPosition(initialVelocity, 
int(trajectoryAngle), age);
 
        if (dieAtMidFlight)
        {
Index: netpanzer/src/NetPanzer/Classes/Network/ClientConnectDaemon.cpp
diff -u netpanzer/src/NetPanzer/Classes/Network/ClientConnectDaemon.cpp:1.3 
netpanzer/src/NetPanzer/Classes/Network/ClientConnectDaemon.cpp:1.4
--- netpanzer/src/NetPanzer/Classes/Network/ClientConnectDaemon.cpp:1.3 Fri Sep 
 5 22:01:18 2003
+++ netpanzer/src/NetPanzer/Classes/Network/ClientConnectDaemon.cpp     Mon Sep 
 8 17:25:08 2003
@@ -26,6 +26,7 @@
 #include "GameConfig.hpp"
 #include "GameManager.hpp"
 
+#include "Log.hpp"
 #include "ConnectNetMessage.hpp"
 #include "ConsoleInterface.hpp"
 
@@ -80,7 +81,7 @@
   char buf[80];
   
   join_request_ack_mesg = (ClientConnectJoinRequestAck *) message;
-  
+ 
   switch( join_request_ack_mesg->result_code )
    {
     case _join_request_result_success :
@@ -107,6 +108,10 @@
      connection_state = _connect_state_connect_failure;
      failure_display_timer.reset();
     break;
+
+       default:
+        LOG ( ("Unknown ACk result?!?") );
+        break;
    }  
  
  } 
Index: netpanzer/src/NetPanzer/Classes/Network/NetworkClient.cpp
diff -u netpanzer/src/NetPanzer/Classes/Network/NetworkClient.cpp:1.6 
netpanzer/src/NetPanzer/Classes/Network/NetworkClient.cpp:1.7
--- netpanzer/src/NetPanzer/Classes/Network/NetworkClient.cpp:1.6       Sun Sep 
 7 14:39:32 2003
+++ netpanzer/src/NetPanzer/Classes/Network/NetworkClient.cpp   Mon Sep  8 
17:25:08 2003
@@ -53,6 +53,7 @@
 
 void NetworkClient::netMessageClientKeepAlive( NetMessage *message )
  {
+        LOG ( ("keep alive.") );
   keep_alive_timer.reset();
  }
 
@@ -64,10 +65,12 @@
 
   keep_alive_state = set_keepalive_state_mesg->keep_alive_state;
   keep_alive_timer.reset();  
+  LOG( ("Set Keepalive from server: %d", keep_alive_state) );
  } 
 
 void NetworkClient::netMessageClientPingAck( NetMessage *message )
  {
+  LOG( ("ping -> pong.") );
   NetworkState::ping_time = (now() - NetworkState::ping_time_stamp) * 1000;
  } 
 
@@ -109,7 +112,10 @@
     case _net_message_id_client_connect_ack :
      netMessageClientConnectAck( message );
     break;
-
+       
+       default:
+         LOG( ("Unknown messageid in NetworkClient::processNetMessage") );
+         break;
    }
  }
 
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.27 
netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.28
--- netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.27     Mon Sep  8 
15:17:48 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.cpp  Mon Sep  8 17:25:09 2003
@@ -38,6 +38,7 @@
 #ifdef UNIX
 #include "UILib/SDL/SDLSound.hpp"
 #endif
+#include "UILib/DummySound.hpp"
 
 #ifdef WIN32
 #include "NetworkServerWinSock.hpp"
@@ -203,6 +204,10 @@
 
 void GameManager::initializeSoundSubSystem()
 {
+       if(execution_mode == _execution_mode_dedicated_server) {
+               sound = new DummySound();
+               return;
+       }
 #ifdef WIN32
     sound = new DirectSound(); 
 #endif
@@ -1037,6 +1042,7 @@
 bool GameManager::dedicatedBootStrap()
 {
        try {
+               initializeSoundSubSystem(); // we load a dummy sound driver
                dedicatedLoadGameData();
                initializeGameObjects();
                initializeGameLogic();
@@ -1643,8 +1649,11 @@
   //winsock hack
   //JoinSession( gapp.hwndApp );
   //InitStreamClient(gapp.hwndApp);
-  Timer wait;
+  CLIENT->joinSession("127.0.0.1");
   
+  // XXX how should that work? we can't process (network) events while waiting
+#if 0
+  Timer wait;
   if ( CLIENT->joinSession() == false )
    {
     lobbyView.scrollAndUpdate( "FAILED TO JOIN NETPANZER SESSION" );
@@ -1654,6 +1663,7 @@
     lobbyView.toggleMainMenu();      
     return;
    }
+#endif
 
   ClientConnectDaemon::startConnectionProcess();
   sound->PlayTankIdle();
@@ -1684,7 +1694,7 @@
 
 // ******************************************************************
 
-// custom version of fgets that doesn't return the trailing \n
+// custom version of readString that doesn't return the trailing \n
 static inline void readString(char* buffer, size_t buffersize, FILE* file)
 {
        fgets(buffer, buffersize, file);
Index: netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp:1.5 
netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp:1.6
--- netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp:1.5   Mon Sep 
 8 11:32:05 2003
+++ netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp       Mon Sep 
 8 17:25:09 2003
@@ -19,6 +19,7 @@
 
 #include "Exception.hpp"
 #include "Log.hpp"
+#include "Desktop.hpp"
 #include "NetworkGlobals.hpp"
 #include "NetworkState.hpp"
 #include "NetworkClientUnix.hpp"
@@ -41,14 +42,15 @@
 int NetworkClientUnix::startEnumeration(ConnectionAddress )
 {
        LOG( ("Server enumeration not implemented yet!") );
+       Desktop::setVisibility("IPAddressView", true);
        return false;
 }
 
 int NetworkClientUnix::startEnumeration( )   
 {
        LOG( ("Server enumeration not implemented yet!") );
-       //Desktop::setVisibility("IPAddressView", true);
-       return false; 
+       Desktop::setVisibility("IPAddressView", true);
+       return false;
 }
 
 int NetworkClientUnix::stopEnumeration( void )
@@ -78,6 +80,7 @@
 {
        delete clientsocket;
        clientsocket = 0;
+       LOG( ("Trying to join server '%s'.\n", session_name) );
        try {
                clientsocket = new ClientSocket(session_name, 
_NETPANZER_DEFAULT_PORT_TCP);
        } catch(Exception e) {
@@ -85,6 +88,8 @@
                return false;
        }
 
+       connection_type = _connection_network;
+
        return true;
 }
 
@@ -114,6 +119,9 @@
        if(!clientsocket)
                return;
 
+       LOG( ( "SEND >> Class: %d ID: %d", message->message_class,
+                                                                  
message->message_id) );      
+       
        message->size = size;
        clientsocket->sendMessage((char*) message, message->size,
                                          ! (flags & 
_network_send_no_guarantee) );
@@ -135,7 +143,7 @@
                                                                                
 message->message_id) );
 
          if ( message->message_class == _net_message_class_client_server )
-         {  processNetMessage( message ); }
+         { processNetMessage( message ); }
 
          NetworkState::incPacketsReceived( net_packet.packet_size );
 
@@ -164,6 +172,7 @@
 
 void NetworkClientUnix::checkIncoming()
 {
-       if(clientsocket)
+       if(clientsocket) {
                clientsocket->read();
+       }
 }
Index: netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp:1.8 
netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp:1.9
--- netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp:1.8     Sun Sep 
 7 16:49:03 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp Mon Sep  8 
17:25:09 2003
@@ -87,6 +87,7 @@
        }
        else if (strcmp(MenuTemplateView::currentMultiView, "JoinView") == 0)
        {
+               printf("EnteringJoinView.\n");
                Desktop::setVisibilityAllWindows(false);
                Desktop::setVisibility("JoinView", true);
                Desktop::setVisibility("GetSessionHostView", true);
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/GetSessionView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/GetSessionView.cpp:1.7 
netpanzer/src/NetPanzer/Views/MainMenu/Multi/GetSessionView.cpp:1.8
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/GetSessionView.cpp:1.7 Sun Sep 
 7 10:04:47 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/GetSessionView.cpp     Mon Sep 
 8 17:25:09 2003
@@ -86,20 +86,23 @@
        else if (GameConfig::GetHostOrJoin() == _game_session_join)
        {
      CLIENT->openSession();
- 
+
+        // XXX hack
+        CLIENT->startEnumeration();
+                /*
      if ( CLIENT->startEnumeration( ) == false )
       {
        Desktop::setVisibilityAllWindows(false);
           Desktop::setVisibility("GetSessionView", true);
       }
      else
-      {
+      {*/
        Desktop::setVisibility("JoinView", true);
           Desktop::setVisibility("GetSessionHostView", true);
           Desktop::setVisibility("UnitSelectionView", true);
           Desktop::setVisibility("FlagSelectionView", true);
           Desktop::setVisibility("PlayerNameView", true);     
-      }
+      //}
      
      /* winsock hack
      bool minimize;
@@ -150,7 +153,7 @@
           end winsock hack*/
 
       
-         //Desktop::setVisibility("IPAddressView", true);
+         Desktop::setVisibility("IPAddressView", true);
             //Desktop::setVisibility("JoinView", true);
             //Desktop::setVisibility("GetSessionHostView", true);
             //Desktop::setVisibility("UnitSelectionView", true);
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/IPAddressView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/IPAddressView.cpp:1.3 
netpanzer/src/NetPanzer/Views/MainMenu/Multi/IPAddressView.cpp:1.4
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/IPAddressView.cpp:1.3  Fri Sep 
 5 22:01:20 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/IPAddressView.cpp      Mon Sep 
 8 17:25:09 2003
@@ -15,8 +15,8 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-
 #include <config.h>
+
 #include "IPAddressView.h"
 #include "Desktop.hpp"
 #include "GameViewGlobals.hpp"
@@ -40,6 +40,8 @@
  strcpy( address.string_rep, szServerName );
 
  ret_val = CLIENT->startEnumeration( address );
+ // XXX hack
+ ret_val = 1;
  
  if(ret_val == 1)
  {
Index: netpanzer/src/UILib/Network/Client.cpp
diff -u netpanzer/src/UILib/Network/Client.cpp:1.1 
netpanzer/src/UILib/Network/Client.cpp:1.2
--- netpanzer/src/UILib/Network/Client.cpp:1.1  Sun Sep  7 10:04:48 2003
+++ netpanzer/src/UILib/Network/Client.cpp      Mon Sep  8 17:25:09 2003
@@ -1,17 +1,18 @@
 #include <config.h>
 
 #include <string.h>
+#include "ServerSocket.hpp"
 #include "Client.hpp"
 
-Client::Client()
+Client::Client(ServerSocket* newserver)
                : tcpsocket(0), headerincomplete(false),
                  messageincomplete(0), udpenabled(false), tempoffset(0),
-                 id(0)
+                 id(0), server(newserver)
 {
        memset(&udpaddress, 0, sizeof(IPaddress));
 }
 
 Client::~Client()
 {
-       SDLNet_TCP_Close(tcpsocket);
+       server->closeConnection(this);
 }
Index: netpanzer/src/UILib/Network/Client.hpp
diff -u netpanzer/src/UILib/Network/Client.hpp:1.2 
netpanzer/src/UILib/Network/Client.hpp:1.3
--- netpanzer/src/UILib/Network/Client.hpp:1.2  Sun Sep  7 14:39:33 2003
+++ netpanzer/src/UILib/Network/Client.hpp      Mon Sep  8 17:25:09 2003
@@ -3,12 +3,14 @@
 
 #include <SDL_net.h>
 
+class ServerSocket;
+
 /** This class keep data from a single client that is connected to the server
  */
 class Client
 {
 public:
-       Client();
+       Client(ServerSocket* server);
        ~Client();
        
        TCPsocket tcpsocket;
@@ -23,6 +25,8 @@
 
        typedef Uint32 ID;
        ID id;
+
+       ServerSocket* server;
 };
 
 #endif
Index: netpanzer/src/UILib/Network/ClientList.cpp
diff -u netpanzer/src/UILib/Network/ClientList.cpp:1.1 
netpanzer/src/UILib/Network/ClientList.cpp:1.2
--- netpanzer/src/UILib/Network/ClientList.cpp:1.1      Sun Sep  7 10:04:48 2003
+++ netpanzer/src/UILib/Network/ClientList.cpp  Mon Sep  8 17:25:09 2003
@@ -27,9 +27,9 @@
 {
 }
 
-Client* ClientList::add(TCPsocket socket)
+Client* ClientList::add(ServerSocket* server, TCPsocket socket)
 {
-       Client* client = new Client();
+       Client* client = new Client(server);
        client->tcpsocket = socket;
        client->id = nextid++;
        clients.push_back(client);
Index: netpanzer/src/UILib/Network/ClientList.hpp
diff -u netpanzer/src/UILib/Network/ClientList.hpp:1.1 
netpanzer/src/UILib/Network/ClientList.hpp:1.2
--- netpanzer/src/UILib/Network/ClientList.hpp:1.1      Sun Sep  7 10:04:48 2003
+++ netpanzer/src/UILib/Network/ClientList.hpp  Mon Sep  8 17:25:09 2003
@@ -22,13 +22,15 @@
 #include <SDL_net.h>
 #include "Client.hpp"
 
+class ServerSocket;
+
 class ClientList
 {
 public:
        ClientList();
        ~ClientList();
        
-       Client* add(TCPsocket socket);
+       Client* add(ServerSocket* server, TCPsocket socket);
        
        Client* getClientFromID(Client::ID id);
 
Index: netpanzer/src/UILib/Network/ClientSocket.cpp
diff -u netpanzer/src/UILib/Network/ClientSocket.cpp:1.1 
netpanzer/src/UILib/Network/ClientSocket.cpp:1.2
--- netpanzer/src/UILib/Network/ClientSocket.cpp:1.1    Sun Sep  7 14:40:23 2003
+++ netpanzer/src/UILib/Network/ClientSocket.cpp        Mon Sep  8 17:25:09 2003
@@ -25,31 +25,32 @@
 
 ClientSocket::ClientSocket(const char* servername, Uint16 port)
 {
-       // create a UDP socket
-       udpsocket = SDLNet_UDP_Open(0);
-       if(!udpsocket)
-               throw Exception("couldn't open udp socket.");
-
        // resolve server name
        IPaddress serverip;
        // XXX why deosn't ResolveHost take a const char*? Is this cast safe?
        if(SDLNet_ResolveHost(&serverip, const_cast<char*>(servername),
                                                  port) < 0) {
-               SDLNet_UDP_Close(udpsocket);
                throw Exception("couldn't resolve name '%s'.", servername);
        }
 
        tcpsocket = SDLNet_TCP_Open(&serverip);
        if(!tcpsocket) {
-               SDLNet_UDP_Close(udpsocket);
                throw Exception("couldn't open tcp connection to server 
'%s:%u'.",
                                                servername, port);
        }
+
+       socketset = SDLNet_AllocSocketSet(1);
+       if(!socketset) {
+               SDLNet_TCP_Close(tcpsocket);
+               throw Exception("couldn't allocate socket set.");
+       }
+       SDLNet_TCP_AddSocket(socketset, tcpsocket);
 }
 
 ClientSocket::~ClientSocket()
 {
-       SDLNet_UDP_Close(udpsocket);
+       SDLNet_TCP_DelSocket(socketset, tcpsocket);
+       SDLNet_FreeSocketSet(socketset);
        SDLNet_TCP_Close(tcpsocket);
 }
 
@@ -66,12 +67,13 @@
        static bool bHeaderIncomplete = false;
 
        // is data available?
+       SDLNet_CheckSockets(socketset, 0);
        if(!SDLNet_SocketReady(tcpsocket))
                return;
 
        int iBytesReceived = SDLNet_TCP_Recv(tcpsocket, RecvBuffer,
                                                                                
 sizeof(RecvBuffer));
-       if(iBytesReceived<=0) {
+       if(iBytesReceived<0) {
                LOG( ("Connection lost to server: %s", SDLNet_GetError()) );
                return;
        }
Index: netpanzer/src/UILib/Network/ClientSocket.hpp
diff -u netpanzer/src/UILib/Network/ClientSocket.hpp:1.1 
netpanzer/src/UILib/Network/ClientSocket.hpp:1.2
--- netpanzer/src/UILib/Network/ClientSocket.hpp:1.1    Sun Sep  7 14:40:23 2003
+++ netpanzer/src/UILib/Network/ClientSocket.hpp        Mon Sep  8 17:25:09 2003
@@ -31,10 +31,9 @@
 
 private:
        void readTCP();
-       void readUDP();
        
-       UDPsocket udpsocket;
        TCPsocket tcpsocket;
+       SDLNet_SocketSet socketset;
 };
 
 #endif
Index: netpanzer/src/UILib/Network/ServerSocket.cpp
diff -u netpanzer/src/UILib/Network/ServerSocket.cpp:1.2 
netpanzer/src/UILib/Network/ServerSocket.cpp:1.3
--- netpanzer/src/UILib/Network/ServerSocket.cpp:1.2    Sun Sep  7 14:39:33 2003
+++ netpanzer/src/UILib/Network/ServerSocket.cpp        Mon Sep  8 17:25:09 2003
@@ -43,12 +43,18 @@
                throw Exception("couldn't open TCP socket on port %d: %s", 
tcpport,
                                                SDLNet_GetError());
 
+       sockets = SDLNet_AllocSocketSet(64);
+       if(!sockets) {
+               SDLNet_TCP_Close(tcpsocket);
+               throw Exception("couldn't allocate socket set.");
+       }
        clientlist = new ClientList();
 }
 
 ServerSocket::~ServerSocket()
 {
        delete clientlist;
+       SDLNet_FreeSocketSet(sockets);
        SDLNet_TCP_Close(tcpsocket);
 }
 
@@ -69,7 +75,11 @@
 {
        TCPsocket clientsocket;
        while ( (clientsocket = SDLNet_TCP_Accept(tcpsocket)) ) {
-               Client* client = clientlist->add(clientsocket);
+               if(SDLNet_TCP_AddSocket(sockets, clientsocket) < 0) {
+                       LOG ( ("Too many connections to server, dropping 
client.") );
+                       return;
+               }
+               Client* client = clientlist->add(this, clientsocket);
 
                // Put message about connecting client into message queue
                TransportClientAccept clientacceptmessage;
@@ -81,6 +91,8 @@
 
 void ServerSocket::readTCP()
 {
+       SDLNet_CheckSockets(sockets, 0);
+       
        // Iterate through client list and check whether data arrived
        ClientList::ClientIterator i;
        for(i = clientlist->begin(); i != clientlist->end(); i++) {
@@ -320,6 +332,12 @@
                throw Exception("Error while sending to client %lu: %s", 
client->id,
                                SDLNet_GetError());
        }
+}
+
+void ServerSocket::closeConnection(Client* client)
+{
+       SDLNet_TCP_DelSocket(sockets, client->tcpsocket);
+       SDLNet_TCP_Close(client->tcpsocket);
 }
 
 void ServerSocket::removeClient(Client::ID clientid)
Index: netpanzer/src/UILib/Network/ServerSocket.hpp
diff -u netpanzer/src/UILib/Network/ServerSocket.hpp:1.2 
netpanzer/src/UILib/Network/ServerSocket.hpp:1.3
--- netpanzer/src/UILib/Network/ServerSocket.hpp:1.2    Sun Sep  7 14:39:33 2003
+++ netpanzer/src/UILib/Network/ServerSocket.hpp        Mon Sep  8 17:25:09 2003
@@ -33,12 +33,17 @@
                                         bool realiable = true);
        void removeClient(Client::ID clientid);
 
+protected:
+       friend class Client;
+       void closeConnection(Client* client);
+
 private:
        void acceptNewClients();
        void readTCP();
        void readClientTCP(Client* client);
        
        TCPsocket tcpsocket;
+       SDLNet_SocketSet sockets;
        ClientList* clientlist;
 };
 
Index: netpanzer/src/UILib/SDL/SDLDraw.cpp
diff -u netpanzer/src/UILib/SDL/SDLDraw.cpp:1.9 
netpanzer/src/UILib/SDL/SDLDraw.cpp:1.10
--- netpanzer/src/UILib/SDL/SDLDraw.cpp:1.9     Mon Sep  8 16:29:10 2003
+++ netpanzer/src/UILib/SDL/SDLDraw.cpp Mon Sep  8 17:25:09 2003
@@ -47,6 +47,7 @@
 {
        Uint32 flags = 0;
        flags |= fullscreen ? SDL_FULLSCREEN : 0;
+       flags |= SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE;
        FrontBuffer = SDL_SetVideoMode(width, height, bpp, flags);
        if(FrontBuffer==NULL)
                return false;




reply via email to

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