netpanzer-cvs
[Top][All Lists]
Advanced

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

[netPanzer-CVS] netpanzer/src ChangeLog Lib/FindFirst.cpp Lib/2...


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer/src ChangeLog Lib/FindFirst.cpp Lib/2...
Date: Sat, 06 Sep 2003 13:15:35 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/09/06 13:15:34

Modified files:
        src            : ChangeLog 
        src/Lib        : FindFirst.cpp 
        src/Lib/2D     : Surface.cpp 
        src/NetPanzer/Core/unix: main.cpp 
        src/NetPanzer/Interfaces: GameManager.cpp 
        src/NetPanzer/Interfaces/unix: NetworkServerUnix.cpp 
                                       NetworkServerUnix.hpp 
        src/NetPanzer/Views/MainMenu/Multi: FlagSelectionView.cpp 
Added files:
        src/NetPanzer/Interfaces/unix: NetworkClientUnix.cpp 
                                       NetworkClientUnix.hpp 

Log message:
        Ladies and gentlemen:
        The main menu is display :) Be happy. (See Changelog for changes)

Patches:
Index: netpanzer/src/ChangeLog
diff -u netpanzer/src/ChangeLog:1.4 netpanzer/src/ChangeLog:1.5
--- netpanzer/src/ChangeLog:1.4 Sat Sep  6 11:39:24 2003
+++ netpanzer/src/ChangeLog     Sat Sep  6 13:15:34 2003
@@ -11,6 +11,10 @@
 -replaced all \\ in paths with / (gotta love sed). Yes, I made sure that I only
  change paths (I looked at the list of stuff I change, before applying the sed
  command)
+-added Stub for SDLSound implementation
+-added a basic SDL Event loop
+-fixed more small issues
+=> the main menu is displayed now and the Exit and Options buttons work :)
 
 ------------
 prior changes (not complete)
Index: netpanzer/src/Lib/2D/Surface.cpp
diff -u netpanzer/src/Lib/2D/Surface.cpp:1.8 
netpanzer/src/Lib/2D/Surface.cpp:1.9
--- netpanzer/src/Lib/2D/Surface.cpp:1.8        Sat Sep  6 11:39:24 2003
+++ netpanzer/src/Lib/2D/Surface.cpp    Sat Sep  6 13:15:34 2003
@@ -29,6 +29,7 @@
 #include "gapp.hpp"
 #include "TimerInterface.hpp"
 #include "Span.hpp"
+#include "Exception.hpp"
 
 #ifdef MSVC
 #pragma pack(1)
@@ -3956,9 +3957,7 @@
 
        FILE *fp = fopen(charfilename, "rb");
        if (fp == 0)
-       {
-               assert(false);
-       }
+               throw Exception("couldn't load font '%s'.", charfilename);
 
        for (int y = 0; y < ascii8x8.getPix().y; y++)
        {
@@ -3983,9 +3982,7 @@
 
        FILE *fp = fopen(charfilename, "rb");
        if (fp == 0)
-       {
-               assert(false);
-       }
+               throw Exception("couldn't load font '%s'.", charfilename);
 
        for (int y = 0; y < ascii5x5.getPix().y; y++)
        {
Index: netpanzer/src/Lib/FindFirst.cpp
diff -u netpanzer/src/Lib/FindFirst.cpp:1.2 netpanzer/src/Lib/FindFirst.cpp:1.3
--- netpanzer/src/Lib/FindFirst.cpp:1.2 Sat Sep  6 12:06:18 2003
+++ netpanzer/src/Lib/FindFirst.cpp     Sat Sep  6 13:15:34 2003
@@ -54,4 +54,4 @@
        findhandle_t* handle = (findhandle_t*) ihandle;
        printf ("closed glob");
        globfree(&handle->globbuf);
-}
+} 
Index: netpanzer/src/NetPanzer/Core/unix/main.cpp
diff -u netpanzer/src/NetPanzer/Core/unix/main.cpp:1.3 
netpanzer/src/NetPanzer/Core/unix/main.cpp:1.4
--- netpanzer/src/NetPanzer/Core/unix/main.cpp:1.3      Sat Sep  6 11:18:19 2003
+++ netpanzer/src/NetPanzer/Core/unix/main.cpp  Sat Sep  6 13:15:34 2003
@@ -5,6 +5,10 @@
 
 #include "Log.hpp"
 #include "GameManager.hpp"
+#include "MouseInterface.hpp"
+#include "cMouse.hpp"
+
+bool HandleSDLEvents();
 
 int main(int argc, char** argv)
 {
@@ -23,11 +27,70 @@
        LOG( ("Initialisation succeeded.") );
 
        while(1) {
+               SDL_PumpEvents();
                GameManager::mainLoop();
-               // XXX handle SDL events here
+       
+               if(HandleSDLEvents() == true) {
+                       LOG( ("quitting main loop.") );
+                       break;
+               }
        }
        
        GameManager::shutdown();
-       return 1;
+       LOG ( ("successfull shutdown.") );
+
+       SDL_Quit();
+
+       return 0;
+}
+
+/** This functions iterates throgh the SDL event queue.
+ * It returns true if a quit message has been received, otherwise false.
+ */
+bool HandleSDLEvents()
+{
+       static SDL_Event event;
+
+       while(SDL_PollEvent(&event)) {
+               switch (event.type) {
+                       case SDL_QUIT:
+                               return true;
+                               break;
+                       case SDL_MOUSEBUTTONDOWN:
+                               switch(event.button.button) {
+                                       case 1: 
+                                               
MouseInterface::setLeftButtonDown();
+                                               
cMouse::setButtonMask(LMOUSE_BUTTON_MASK);
+                                               break;
+                                       case 3: 
+                                               
MouseInterface::setRightButtonDown(); 
+                                               
cMouse::setButtonMask(RMOUSE_BUTTON_MASK);
+                                               break;
+                                       case 2:
+                                               
MouseInterface::setMiddleButtonDown();
+                                               
cMouse::setButtonMask(MMOUSE_BUTTON_MASK);
+                                               break;
+                               }
+                               break;
+                       case SDL_MOUSEBUTTONUP:
+                               switch(event.button.button) {
+                                       case 1:
+                                               
MouseInterface::setLeftButtonUp();
+                                               
cMouse::clearButtonMask(!LMOUSE_BUTTON_MASK);
+                                               break;
+                                       case 3:
+                                               
MouseInterface::setRightButtonUp();
+                                               
cMouse::clearButtonMask(!RMOUSE_BUTTON_MASK);
+                                               break;
+                                       case 2:
+                                               
MouseInterface::setMiddleButtonUp();
+                                               
cMouse::clearButtonMask(!MMOUSE_BUTTON_MASK);
+                                               break;
+                               }
+                               break;
+               }
+       }
+
+       return false;
 }
 
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.15 
netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.16
--- netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.15     Sat Sep  6 
11:39:25 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.cpp  Sat Sep  6 13:15:34 2003
@@ -37,6 +37,9 @@
 #include "DirectInput.hpp"
 #include "DSound.hpp"
 #endif
+#ifdef UNIX
+#include "UILib/SDL/SDLSound.hpp"
+#endif
 
 #ifdef WIN32
 #include "NetworkServerWinSock.hpp"
@@ -44,6 +47,10 @@
 //#include "NetworkServerDPlay.hpp"
 //#include "NetworkClientDPlay.hpp"
 #endif
+#ifdef UNIX
+#include "NetworkServerUnix.hpp"
+#include "NetworkClientUnix.hpp"
+#endif
 
 #include "UILib/UIDraw.hpp"
 #include "UILib/Sound.hpp"
@@ -211,22 +218,27 @@
 {
 #ifdef WIN32
     sound = new DirectSound(); 
-    if (!sound->initialize())
+#endif
+#ifdef USE_SDL
+       sound = new SDLSound();
+#endif
+    if (!sound || !sound->initialize())
     {
-       LOG( ( "Failure to initialize DirectSound Sub-system" ) );
-       delete sound;
-       sound = 0;
+               LOG( ( "Failure to initialize DirectSound Sub-system" ) );
+               delete sound;
+               sound = 0;
     } 
-#endif
 }
 
 // ******************************************************************
 
 void GameManager::shutdownSoundSubSystem()
 {
-#ifdef WIN32
-    sound->shutdown();
-#endif
+       if(sound) {
+               sound->shutdown();
+               delete sound;
+               sound = 0;
+       }
 }
 
 // ******************************************************************
@@ -521,6 +533,10 @@
        SERVER = new NetworkServerWinSock();
        CLIENT = new NetworkClientWinSock();
 #endif
+#ifdef UNIX
+       SERVER = new NetworkServerUnix();
+       CLIENT = new NetworkClientUnix();
+#endif
 
        ServerMessageRouter::initialize();
        ClientMessageRouter::initialize();
@@ -1809,16 +1825,21 @@
 // ******************************************************************
 void GameManager::exitNetPanzer()
 {
+#if 0
+  // XXX 
   // NOTE: Hack
   sound->StopTankIdle(); 
+#endif
 
   quitNetPanzerGame();
 
 #ifdef WIN32
   PostMessage(gapp.hwndApp, WM_CLOSE, 0, 0);
-#else
-  // XXX not the nice method...
-  exit(1);
+#endif
+#ifdef USE_SDL
+       SDL_Event event;
+       event.type = SDL_QUIT;
+       SDL_PushEvent(&event);
 #endif
 }
 
Index: netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp:1.1 
netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp:1.2
--- netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp:1.1   Mon Sep 
 1 16:24:21 2003
+++ netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp       Sat Sep 
 6 13:15:34 2003
@@ -15,11 +15,11 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-#ifdef NOTREADYYET
 #include <config.h>
 
-#include "NetworkServerUnix.hpp"
+// XXX stub implementation, mine still has bugs, but will come soon
 
+#include "NetworkServerUnix.hpp"
 #include "gapp.hpp"
 
 #include "NetMessageLog.hpp"
@@ -39,33 +39,36 @@
 
 void NetworkServerUnix::shutdownClientTransport( PlayerID &client_id )
 {
-       DelClientByWinsockID( client_id.getDPID() );
+       //DelClientByWinsockID( client_id.getDPID() );
 }
 
 int NetworkServerUnix::openSession( int connection_type, int session_flags )
 {
-       return( InitWinSock(gapp.hwndApp) );
+       return 0;
 }
 
 int NetworkServerUnix::hostSession( void )
 {
+#if 0
        //winsock hack
        if(InitStreamServer(gapp.hwndApp) == false) return false;
 
        if(InitDGramServer(gapp.hwndApp)== false) return false;
+#endif
   
        return true;
 }
 
 int NetworkServerUnix::closeSession( void )
 {
-       ShutdownWinSockServer();
+       //ShutdownWinSockServer();
        return true;
 }
 
 int NetworkServerUnix::sendMessage( NetMessage *message, unsigned long size,
                                                                        int 
flags )
 {
+#if 0
        int sock_ret_val;
        int net_error_code;
 
@@ -115,6 +118,7 @@
 
   
        NetworkState::incPacketsSent( size ); 
+#endif
   
        return true;
 }
@@ -122,6 +126,7 @@
 int NetworkServerUnix::sendMessage( NetMessage *message, unsigned long size,
                                                                        
PlayerID &player_id, int flags )
 {
+#if 0
        ServerClientListData *client_data_ptr = 0;
        int ret_val;
 
@@ -151,12 +156,14 @@
 
        if( ret_val != WS_OK )
                return winsockErrorToNetworkError( ret_val );
+#endif
 
        return _network_ok;
 }
 
 int NetworkServerUnix::getMessage( NetMessage *message )
 {
+#if 0
        updateKeepAliveState();
       
        if ( loop_back_recv_queue.isReady() )
@@ -183,8 +190,8 @@
                        return true;
                }
        } // ** else 
+#endif
     
        return false;
 }
-#endif
 
Index: netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.hpp:1.1 
netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.hpp:1.2
--- netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.hpp:1.1   Mon Sep 
 1 16:24:21 2003
+++ netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.hpp       Sat Sep 
 6 13:15:34 2003
@@ -26,8 +26,8 @@
 class NetworkServerUnix : public NetworkServer
 {
 public:
-       NetworkServerWinSock();
-       virtual ~NetworkServerWinSock();
+       NetworkServerUnix();
+       virtual ~NetworkServerUnix();
    
        virtual int openSession( int connection_type, int session_flags );
        virtual int hostSession( void );
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.5 
netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.6
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.5      
Sat Sep  6 11:39:25 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp  Sat Sep 
 6 13:15:34 2003
@@ -15,14 +15,13 @@
 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 "FlagSelectionView.hpp"
 #include "gapp.hpp"
 #include "GameView.hpp"
 #include "GameViewGlobals.hpp"
-
+#include "Exception.hpp"
 
 Surface playerFlag;
 int     playerFlagSelected = 0;
@@ -67,7 +66,9 @@
 //---------------------------------------------------------------------------
 void FlagSelectionView::init()
 {
-       playerFlag.loadAllBMPInDirectory("pics/flags/netpmenu/");
+       if (playerFlag.loadAllBMPInDirectory("pics/flags/netpmenu/") <= 0)
+               throw Exception("Couldn't find flags for menu in '%s'.",
+                               "pics/flags/netpmenu/");
 
        iXY flagStartOffset(BORDER_SPACE, BORDER_SPACE * 2 + 
playerFlag.getPixY());
 




reply via email to

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