netpanzer-cvs
[Top][All Lists]
Advanced

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

[netPanzer-CVS] netpanzer/src ChangeLog Makefile Lib/FileSystem...


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer/src ChangeLog Makefile Lib/FileSystem...
Date: Sat, 13 Sep 2003 18:38:23 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/09/13 18:38:22

Modified files:
        src            : ChangeLog Makefile 
        src/Lib        : FileSystem.cpp FileSystem.hpp 
        src/Lib/2D     : DigitText.cpp PackedSurface.cpp 
                         PackedSurface.hpp Palette.cpp Surface.cpp 
        src/Lib/Particles: ChunkTrajectoryParticle2D.cpp 
                           ParticleInterface.cpp 
        src/Lib/View   : Desktop.cpp 
        src/NetPanzer/Classes: BonusUnitPowerUp.cpp 
                               EnemyRadarPowerUp.cpp UnitBase.hpp 
                               UnitPowerUp.cpp 
                               WorldInputCmdProcessor.cpp 
        src/NetPanzer/Classes/Units: Abrams.cpp Abrams.hpp Archer.cpp 
                                     Archer.hpp Hammerhead.cpp 
                                     Hammerhead.hpp Humvee.cpp 
                                     Humvee.hpp Leopard.cpp Leopard.hpp 
                                     Lynx.cpp Lynx.hpp M109.cpp M109.hpp 
                                     Scorpion.cpp Scorpion.hpp 
                                     SpahPanzer.cpp SpahPanzer.hpp 
                                     Valentine.cpp Valentine.hpp 
                                     Vehicle.cpp Vehicle.hpp 
        src/NetPanzer/Classes/Weapons: BulletWeapon.cpp MissleWeapon.cpp 
                                       ShellWeapon.cpp Weapon.hpp 
        src/NetPanzer/Core: main.cpp 
        src/NetPanzer/Interfaces: GameManager.cpp MouseInterface.cpp 
                                  MouseInterface.hpp 
                                  ProjectileInterface.cpp 
                                  UnitInterface.cpp 
        src/NetPanzer/Port: Gdatstct.cpp Gdatstct.hpp Globals.h 
        src/NetPanzer/Views/Game: AreYouSureResignView.cpp 
                                  WinnerMesgView.cpp 
        src/UILib      : DummySound.cpp DummySound.hpp Sound.cpp 
                         Sound.hpp 
        src/UILib/SDL  : SDLSound.cpp SDLSound.hpp 

Log message:
        applied sound patch by Ivo (thanks alot)

Patches:
Index: netpanzer/src/ChangeLog
diff -u netpanzer/src/ChangeLog:1.19 netpanzer/src/ChangeLog:1.20
--- netpanzer/src/ChangeLog:1.19        Fri Sep 12 17:37:09 2003
+++ netpanzer/src/ChangeLog     Sat Sep 13 18:38:20 2003
@@ -1,3 +1,6 @@
+14-Sep-2003 by Matze Braun
+-applied sound patch by Ivo Danihelka (thanks alot)
+
 12-Sep-2003 by Matze Braun
 -use the physfs for the colortable cache now
 -removed lots of unused code from Surface class
Index: netpanzer/src/Lib/2D/DigitText.cpp
diff -u netpanzer/src/Lib/2D/DigitText.cpp:1.5 
netpanzer/src/Lib/2D/DigitText.cpp:1.6
--- netpanzer/src/Lib/2D/DigitText.cpp:1.5      Sun Sep  7 16:49:02 2003
+++ netpanzer/src/Lib/2D/DigitText.cpp  Sat Sep 13 18:38:21 2003
@@ -15,17 +15,16 @@
 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 "Exception.hpp"
+#include "FileSystem.hpp"
 #include "DigitText.hpp"
 
-
 Surface         DigitText::charactersNormal;
 Surface         DigitText::charactersNoSpace;
 DIGIT_BLT_MODES DigitText::bltMode = NORMAL_TRANS;
 
-
 // init
 //--------------------------------------------------------------------------
 // Purpose: Load all the characters into a surface of 128 frames.  Then the
@@ -39,9 +38,7 @@
        // NOTE: Make sure the file size is 128 characters.
        char charfilename[] = "pics/chars11x17digit.raw";
 
-       FILE *fp = fopen(charfilename, "rb");
-       if (fp == 0)
-               throw Exception("ERROR: Unable to load %s", charfilename);
+       ReadFile* file = FileSystem::openRead(charfilename);
 
        for (int y = 0; y < charactersNormal.getPixY(); y++)
        {
@@ -50,12 +47,16 @@
                for (int curChar = 0; curChar < 
charactersNormal.getFrameCount(); curChar++)
                {
                        charactersNormal.setFrame(curChar);
-                       fread(charactersNormal.mem + yOffset, 
charactersNormal.getPixX(), 1, fp);
+                       if(!file->read(charactersNormal.mem + yOffset,
+                                               charactersNormal.getPixX(), 1) 
!= 1) {
+                               delete file;
+                               throw Exception("Error while loading font file 
'%s'.",
+                                                               charfilename);
+                       }
                }
        }
 
-       fclose(fp);
-
+       delete file;
 } // DigitText::initFont
 
 //--------------------------------------------------------------------------
Index: netpanzer/src/Lib/2D/PackedSurface.cpp
diff -u netpanzer/src/Lib/2D/PackedSurface.cpp:1.8 
netpanzer/src/Lib/2D/PackedSurface.cpp:1.9
--- netpanzer/src/Lib/2D/PackedSurface.cpp:1.8  Fri Sep 12 10:12:45 2003
+++ netpanzer/src/Lib/2D/PackedSurface.cpp      Sat Sep 13 18:38:21 2003
@@ -22,6 +22,7 @@
 #include "Surface.hpp"
 #include "TimerInterface.hpp"
 #include "Span.hpp"
+#include "FileSystem.hpp"
 #include "Exception.hpp"
 #include "UtilInterface.hpp"
 
@@ -188,82 +189,71 @@
 }
 
 //--------------------------------------------------------------------------
-void PackedSurface::load(const char *filename) {
-       FILE *f = fopen(filename, "rb");
-       
-       if (f == 0)
-               throw Exception("Can't open %s", filename);
-       
-       load(f);
-
-       fclose(f);
-}
-
-//--------------------------------------------------------------------------
-void PackedSurface::save(const char *filename) const {
-       FILE *f = fopen(filename, "wb");
-       if (f == 0) throw Exception("Can't create %s", filename);
-       save(f);
-       fclose(f);
-}
-
-//--------------------------------------------------------------------------
-void PackedSurface::load(FILE *f) {
+void PackedSurface::load(const char* filename) {
+       ReadFile* file = FileSystem::openRead(filename);
+               
        free();
        int version;
-       fread(&version, sizeof(version), 1, f);
+       file->read(&version, sizeof(version), 1);
        if (version < 1) {
+               delete file;
                throw Exception("Invalid PAK file version: %d", version);
        }
        if (version > CURRENT_PAK_VERSION) {
+               delete file;
                throw Exception("PAK file version %d is newer than the .exe 
(%d) you are using, which only supports up to version", version, 
CURRENT_PAK_VERSION);
        }
-       fread(&pix, sizeof(pix), 1, f);
+       file->read(&pix, sizeof(pix), 1);
 
        center = pix / 2;
 
-       fread(&frameCount, sizeof(frameCount), 1, f);
-       fread(&fps, sizeof(fps), 1, f);
-       fread(&offset, sizeof(offset), 1, f);
+       file->read(&frameCount, sizeof(frameCount), 1);
+       file->read(&fps, sizeof(fps), 1);
+       file->read(&offset, sizeof(offset), 1);
        rowOffsetTable = (int *) malloc((pix.y * frameCount + 1) * 
sizeof(*rowOffsetTable));
        if (rowOffsetTable == 0)
        {
+               delete file;
                throw Exception("ERROR: Unable to allocate rowTableOffset for 
PackedSurface.");
        }
-       fread(rowOffsetTable, (pix.y*frameCount + 1)*sizeof(*rowOffsetTable), 
1, f);
+       file->read(rowOffsetTable, (pix.y*frameCount + 
1)*sizeof(*rowOffsetTable), 1);
        packedDataChunk = (BYTE *)malloc(rowOffsetTable[pix.y*frameCount]);
        if (packedDataChunk == 0)
        {
+               delete file;
                throw Exception("ERROR: Unable to allocate packedDataChunk for 
PackedSurface.");
        }
-       fread(packedDataChunk, rowOffsetTable[pix.y*frameCount], 1, f);
-
-       // Quick check for error
-
-       if (ferror(f))
-               throw Exception("Error reading packed surface file!");
+       if(file->read(packedDataChunk, rowOffsetTable[pix.y*frameCount], 1) != 
1)
+               throw Exception("error while reading %s.", filename);
 
        // Add size of rowTableOffset.
        totalByteCount += (pix.y * frameCount + 1) * sizeof(*rowOffsetTable);
 
        // Add size of packedDataChunk.
        totalByteCount += pix.y * frameCount;
+
+       delete file;
 }
 
 //--------------------------------------------------------------------------
-void PackedSurface::save(FILE *f) const {
+void PackedSurface::save(const char* filename) const
+{
+       WriteFile* file = FileSystem::openWrite(filename);
+       
        int version = CURRENT_PAK_VERSION;
-       fwrite(&version, sizeof(version), 1, f);
-       fwrite(&pix, sizeof(pix), 1, f);
-       fwrite(&frameCount, sizeof(frameCount), 1, f);
-       fwrite(&fps, sizeof(fps), 1, f);
-       fwrite(&offset, sizeof(offset), 1, f);
-       fwrite(rowOffsetTable, (pix.y*frameCount + 1)*sizeof(*rowOffsetTable), 
1, f);
-       fwrite(packedDataChunk, rowOffsetTable[pix.y*frameCount], 1, f);
-
-       // Quick check for error
+       file->write(&version, sizeof(version), 1);
+       file->write(&pix, sizeof(pix), 1);
+       file->write(&frameCount, sizeof(frameCount), 1);
+       file->write(&fps, sizeof(fps), 1);
+       file->write(&offset, sizeof(offset), 1);
+       file->write(rowOffsetTable, (pix.y*frameCount + 
1)*sizeof(*rowOffsetTable), 1);
+       if (file->write(packedDataChunk, rowOffsetTable[pix.y*frameCount], 1) 
!= 1)
+       {
+               delete file;    
+               throw Exception("error while writing '%s'.", filename);
+       }
 
-       if (ferror(f)) throw Exception("Error writing packed surface file!");
+       delete file;
 }
 
 //--------------------------------------------------------------------------
Index: netpanzer/src/Lib/2D/PackedSurface.hpp
diff -u netpanzer/src/Lib/2D/PackedSurface.hpp:1.2 
netpanzer/src/Lib/2D/PackedSurface.hpp:1.3
--- netpanzer/src/Lib/2D/PackedSurface.hpp:1.2  Mon Sep  1 16:24:18 2003
+++ netpanzer/src/Lib/2D/PackedSurface.hpp      Sat Sep 13 18:38:21 2003
@@ -85,8 +85,6 @@
 
        void load(const char *filename);
        void save(const char *filename) const;
-       void load(FILE *f);
-       void save(FILE *f) const;
 
        inline void setFPS(float fps)
        {
@@ -138,37 +136,3 @@
 
 #endif // end __PackedSurface_hpp__
 
-/*
-typedef void (*CALLBACK)(void *context);
-
-class WINDOW {
-
-  void close();
-
-  CALLBACK buttonFunc;
-
-}
-
-void closeWindow(void *context) {
-  WINDOW *w = (WINDOW *)context;
-  w->close();
-}
-
-WINDOW::WINDOW() {
-  ...
-  buttonFunc = closeWindow;
-}
-
-
-WINDOW::buttonPushed() {
-  if (buttonFunc != 0) {
-    (*buttonFunc)(this);
-  }
-}
-
-typedef void (WINDOW::*CALLBACK)(void);
-
-CALLBACK buttonFunc = &WINDOW::close;
-
-(*buttonFunc)()
-*/
Index: netpanzer/src/Lib/2D/Palette.cpp
diff -u netpanzer/src/Lib/2D/Palette.cpp:1.8 
netpanzer/src/Lib/2D/Palette.cpp:1.9
--- netpanzer/src/Lib/2D/Palette.cpp:1.8        Fri Sep 12 10:12:45 2003
+++ netpanzer/src/Lib/2D/Palette.cpp    Sat Sep 13 18:38:21 2003
@@ -373,21 +373,20 @@
 {
        assert(filename != 0);
 
-       FILE *fp;
-
        setName(filename);
 
-       if ((fp = fopen(filename, "rb")) == 0)
-               throw Exception("Unable to open palette file: %s", filename);
+       ReadFile* file = FileSystem::openRead(filename);
 
        for (int i = 0; i < 256; i++)
        {
-           fread(&color[i], 3, sizeof(BYTE), fp);
+           if(file->read(&color[i], 3, 1) != 1) {
+                       delete file;
+                       throw Exception("couldn't read file '%s'", filename);
+               }
                originalColor[i] = color[i];
        }
 
-    fclose(fp);
-
+       delete file;
 } // end Palette::loadACT
 
 // findNearestColor
Index: netpanzer/src/Lib/2D/Surface.cpp
diff -u netpanzer/src/Lib/2D/Surface.cpp:1.19 
netpanzer/src/Lib/2D/Surface.cpp:1.20
--- netpanzer/src/Lib/2D/Surface.cpp:1.19       Fri Sep 12 20:15:08 2003
+++ netpanzer/src/Lib/2D/Surface.cpp    Sat Sep 13 18:38:21 2003
@@ -19,6 +19,7 @@
 
 #include <algorithm>
 #include "FindFirst.hpp"
+#include "Log.hpp"
 #include "Surface.hpp"
 #include "FileSystem.hpp"
 #include "UtilInterface.hpp"
@@ -1375,11 +1376,11 @@
 
        fread(&head, sizeof(PIC_HEAD), 1, fp);
 
-       //LOG(("loadRAW -> picName: %s", fileName));
-       //LOG(("head.xPix:          %u", head.xPix));
-       //LOG(("head.yPix:          %u", head.yPix));
-       //LOG(("head.frameCount:     %u", head.frameCount));
-       //LOG(("head.numBytes:      %u", head.xPix*head.yPix*head.frameCount));
+       LOG(("loadRAW -> picName: %s", filename));
+       LOG(("head.xPix:          %u", head.xPix));
+       LOG(("head.yPix:          %u", head.yPix));
+       LOG(("head.frameCount:     %u", head.frameCount));
+       LOG(("head.numBytes:      %u", head.xPix*head.yPix*head.frameCount));
 
        if (ferror(fp))
        {
@@ -3864,7 +3865,7 @@
                bestFitArray[i] = Palette::findNearestColor(sourceColor[i]);
        }
 
-       for (size_t x = 0; x < pix.x * pix.y * frameCount; x++)
+       for (size_t x = 0; x < (size_t) (pix.x * pix.y * frameCount); x++)
        {
                frame0[x] = bestFitArray[frame0[x]];
        }
Index: netpanzer/src/Lib/FileSystem.cpp
diff -u netpanzer/src/Lib/FileSystem.cpp:1.2 
netpanzer/src/Lib/FileSystem.cpp:1.3
--- netpanzer/src/Lib/FileSystem.cpp:1.2        Fri Sep 12 10:12:45 2003
+++ netpanzer/src/Lib/FileSystem.cpp    Sat Sep 13 18:38:20 2003
@@ -17,6 +17,8 @@
 */
 #include <config.h>
 
+#include <stdio.h>
+#include <string.h>
 #include <physfs.h>
 #include "Exception.hpp"
 #include "FileSystem.hpp"
@@ -24,15 +26,96 @@
 void FileSystem::initialize(const char* argv0, const char* company,
                                                        const char* application)
 {
-       if(!PHYSFS_init(argv0) ||
-          !PHYSFS_setSaneConfig(company, application, "zip", 0, 0))
+       if(!PHYSFS_init(argv0))
                throw Exception("failure while initialising physfs: %s",
                                                        PHYSFS_getLastError());
+
+       const char* basedir = PHYSFS_getBaseDir();
+       const char* userdir = PHYSFS_getUserDir();
+       const char* dirsep = PHYSFS_getDirSeparator();
+       char* writedir = new char[strlen(userdir) + strlen(application) + 2];
+       
+       sprintf(writedir, "%s.%s", userdir, application);
+       if(!PHYSFS_setWriteDir(writedir)) {
+               // try to create the directory...
+               char* mkdir = new char[strlen(application)+2];
+               sprintf(mkdir, ".%s", application);
+               if(!PHYSFS_setWriteDir(userdir) || ! PHYSFS_mkdir(mkdir)) {
+                       delete[] writedir;
+                       delete[] mkdir;
+                       throw Exception("failed creating configuration 
directory: '%s': %s",
+                                                       writedir, 
PHYSFS_getLastError());
+               }
+               delete[] mkdir;
+               
+               if (!PHYSFS_setWriteDir(writedir)) {
+                       throw Exception("couldn't set configuration directory 
to '%s': %s",
+                                                       writedir, 
PHYSFS_getLastError());
+               }
+       }
+       printf("WriteDir: %s\n", writedir);
+
+       PHYSFS_addToSearchPath(writedir, 0);
+       PHYSFS_addToSearchPath(basedir, 1);
+
+       delete[] writedir;
+
+       /* Root out archives, and add them to search path... */
+       char* archiveExt = "zip";
+    if (archiveExt != NULL)
+    {
+        char **rc = PHYSFS_enumerateFiles("/");
+        char **i;
+        size_t extlen = strlen(archiveExt);
+        char *ext;
+                                                                               
 
+        for (i = rc; *i != NULL; i++)
+        {
+            size_t l = strlen(*i);
+            if ((l > extlen) && ((*i)[l - extlen - 1] == '.'))
+            {
+                ext = (*i) + (l - extlen);
+                if (strcasecmp(ext, archiveExt) == 0)
+                {
+                    const char *d = PHYSFS_getRealDir(*i);
+                                       char* str = new char[strlen(d) + 
strlen(dirsep) + l + 1];
+                                       sprintf(str, "%s%s%s", d, dirsep, *i);
+                                       PHYSFS_addToSearchPath(str, 1);
+                                       delete[] str;
+                } /* if */
+            } /* if */
+        } /* for */
+                                                                               
 
+        PHYSFS_freeList(rc);
+    } /* if */
 }
 
 void FileSystem::shutdown()
 {
        PHYSFS_deinit();
+}
+
+const char* FileSystem::getRealDir(const char* filename)
+{
+       return PHYSFS_getRealDir(filename);
+}
+
+std::string FileSystem::getRealName(const char* filename)
+{
+       const char* dir = PHYSFS_getRealDir(filename);
+       std::string realname = dir;
+       realname += filename;
+       return realname;
+}
+
+char** FileSystem::enumerateFiles(const char* directory)
+{
+       return PHYSFS_enumerateFiles(directory);
+}
+
+void FileSystem::freeList(char** list)
+{
+       PHYSFS_freeList(list);
 }
 
 WriteFile* FileSystem::openWrite(const char* filename)
Index: netpanzer/src/Lib/FileSystem.hpp
diff -u netpanzer/src/Lib/FileSystem.hpp:1.2 
netpanzer/src/Lib/FileSystem.hpp:1.3
--- netpanzer/src/Lib/FileSystem.hpp:1.2        Fri Sep 12 10:12:45 2003
+++ netpanzer/src/Lib/FileSystem.hpp    Sat Sep 13 18:38:20 2003
@@ -19,6 +19,7 @@
 #ifndef __LIB_FILESYSTEM_HPP__
 #define __LIB_FILESYSTEM_HPP__
 
+#include <string>
 #include <stdint.h>
 #include <stdlib.h>
 #include <physfs.h>
@@ -109,6 +110,12 @@
        static void initialize(const char* argv0, const char* company,
                                                   const char* applicationname);
        static void shutdown();
+
+       static const char* getRealDir(const char* filename);
+       static std::string getRealName(const char* filename);
+       // remember to call freeLisT
+       static char** enumerateFiles(const char* directory);
+       static void freeList(char** list);
        
        static ReadFile* openRead(const char* filename);
        static WriteFile* openAppend(const char* filename);
Index: netpanzer/src/Lib/Particles/ChunkTrajectoryParticle2D.cpp
diff -u netpanzer/src/Lib/Particles/ChunkTrajectoryParticle2D.cpp:1.7 
netpanzer/src/Lib/Particles/ChunkTrajectoryParticle2D.cpp:1.8
--- netpanzer/src/Lib/Particles/ChunkTrajectoryParticle2D.cpp:1.7       Wed Sep 
10 08:32:51 2003
+++ netpanzer/src/Lib/Particles/ChunkTrajectoryParticle2D.cpp   Sat Sep 13 
18:38:21 2003
@@ -188,17 +188,18 @@
        char strBuf[256];
        sprintf(strBuf, "%sgroundChunks.pak", chunkPathPAK);
        tempPackedSurface.save(strBuf);
-
 } // end ChunkTrajectoryParticle2D::createGroundChunks
 
 // createPAKFiles
 //---------------------------------------------------------------------------
 void ChunkTrajectoryParticle2D::createPAKFiles()
 {
+#if 0
        createGroundChunks();
        createBurnGroundChunks();
        createUnitBodyGreenChunks();
        createUnitBodyGrayChunks();
+#endif
 
        
staticPackedGroundChunks.load("pics/particles/chunks/pak/groundChunks.pak");
        
staticPackedBurnGroundChunks.load("pics/particles/chunks/pak/greenUnitChunks.pak");
Index: netpanzer/src/Lib/Particles/ParticleInterface.cpp
diff -u netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.8 
netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.9
--- netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.8       Thu Sep 11 
13:35:46 2003
+++ netpanzer/src/Lib/Particles/ParticleInterface.cpp   Sat Sep 13 18:38:21 2003
@@ -45,6 +45,7 @@
 #include "UnitGlobals.hpp"
 #include "CraterParticle2D.hpp"
 #include "Exception.hpp"
+#include "Sound.hpp"
 
 
 cGrowList <UnitParticleInfo> ParticleInterface::unitParticleInfo;
@@ -446,8 +447,7 @@
         groupTime0 = 0.0f;
 
         //SFX
-               // XXX
-        // dsound.PlayAmbientSound( _not_applicable, _blow_up_tank, 0 );
+        sound->playSound("expl");
 
                iRect gameViewRect;
                WorldViewInterface::getViewWindow(&gameViewRect);
@@ -469,8 +469,7 @@
         groupTime1 = 0.0f;
 
         //SFX
-               // XXX
-        // dsound.PlayAmbientSound( _not_applicable, _blow_up_tank, 0 );
+               sound->playSound("expl");
 
                iRect gameViewRect;
                WorldViewInterface::getViewWindow(&gameViewRect);
Index: netpanzer/src/Lib/View/Desktop.cpp
diff -u netpanzer/src/Lib/View/Desktop.cpp:1.7 
netpanzer/src/Lib/View/Desktop.cpp:1.8
--- netpanzer/src/Lib/View/Desktop.cpp:1.7      Tue Sep  9 13:16:13 2003
+++ netpanzer/src/Lib/View/Desktop.cpp  Sat Sep 13 18:38:21 2003
@@ -139,7 +139,7 @@
 
                                        // mouseActionOffset is relative to the 
current window
                                        mouseActionOffset = mousePos - 
lMouseView->min;
-                                       mouseActions      = 
lMouseView->getMouseActions(mousePos-lMouseView->min);
+                                       mouseActions      = 
lMouseView->getMouseActions(mouseActionOffset);
                                        if (mouseActions != 0)
                                        {
                                                // A standard mouse action is 
supposed to happen here.  Remember
Index: netpanzer/src/Makefile
diff -u netpanzer/src/Makefile:1.14 netpanzer/src/Makefile:1.15
--- netpanzer/src/Makefile:1.14 Fri Sep 12 17:37:09 2003
+++ netpanzer/src/Makefile      Sat Sep 13 18:38:20 2003
@@ -19,7 +19,7 @@
 CFLAGS += -Wall -g3 -O2 $(foreach dir, $(INCLUDEDIRS), -I$(dir))
 
 GOAL = ../netpanzer
-LINKFLAGS += -g3 `sdl-config --libs` -lSDL_net -lSDL_mixer -lphysfs
+LINKFLAGS += -g3 `sdl-config --libs` -lSDL_net -lSDL_mixer -lSDL_image -lphysfs
 CFLAGS += `sdl-config --cflags` -DUNIX
 
 ifeq ($(PROFILING),yes)
Index: netpanzer/src/NetPanzer/Classes/BonusUnitPowerUp.cpp
diff -u netpanzer/src/NetPanzer/Classes/BonusUnitPowerUp.cpp:1.5 
netpanzer/src/NetPanzer/Classes/BonusUnitPowerUp.cpp:1.6
--- netpanzer/src/NetPanzer/Classes/BonusUnitPowerUp.cpp:1.5    Wed Sep 10 
08:32:52 2003
+++ netpanzer/src/NetPanzer/Classes/BonusUnitPowerUp.cpp        Sat Sep 13 
18:38:21 2003
@@ -58,7 +58,7 @@
   PlayerID player_id;
   iXY map_loc;
   
-  sound->PlayPowerUpSound();
+  sound->playPowerUpSound();
 
     unit = UnitInterface::getUnit( unit_id );
   
@@ -138,7 +138,7 @@
  {
   PlayerID local_player_id;
  
-  sound->PlayPowerUpSound(); 
+  sound->playPowerUpSound(); 
   powerup_state.life_cycle_state = _power_up_lifecycle_state_inactive; 
   
   local_player_id = PlayerInterface::getLocalPlayerID();
Index: netpanzer/src/NetPanzer/Classes/EnemyRadarPowerUp.cpp
diff -u netpanzer/src/NetPanzer/Classes/EnemyRadarPowerUp.cpp:1.5 
netpanzer/src/NetPanzer/Classes/EnemyRadarPowerUp.cpp:1.6
--- netpanzer/src/NetPanzer/Classes/EnemyRadarPowerUp.cpp:1.5   Wed Sep 10 
08:32:52 2003
+++ netpanzer/src/NetPanzer/Classes/EnemyRadarPowerUp.cpp       Sat Sep 13 
18:38:21 2003
@@ -55,7 +55,7 @@
   UnitBase *unit;
   PlayerID player_id;
   
-  sound->PlayPowerUpSound();
+  sound->playPowerUpSound();
 
   unit = UnitInterface::getUnit( unit_id );
   
@@ -106,7 +106,7 @@
 
 void EnemyRadarPowerUp::onHit( PowerUpHitMesg *message  )
  {
-  sound->PlayPowerUpSound(); 
+  sound->playPowerUpSound(); 
   PlayerID local_player_id;
   
   local_player_id = PlayerInterface::getLocalPlayerID();
Index: netpanzer/src/NetPanzer/Classes/UnitBase.hpp
diff -u netpanzer/src/NetPanzer/Classes/UnitBase.hpp:1.2 
netpanzer/src/NetPanzer/Classes/UnitBase.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/UnitBase.hpp:1.2    Mon Sep  1 16:24:20 2003
+++ netpanzer/src/NetPanzer/Classes/UnitBase.hpp        Sat Sep 13 18:38:21 2003
@@ -45,6 +45,8 @@
 
    virtual void offloadGraphics( SpriteSorter &sorter ) { }
   
+   virtual void soundSelected() = 0;
+
   protected:
    UnitBase *groupLinkNext;
  
Index: netpanzer/src/NetPanzer/Classes/UnitPowerUp.cpp
diff -u netpanzer/src/NetPanzer/Classes/UnitPowerUp.cpp:1.5 
netpanzer/src/NetPanzer/Classes/UnitPowerUp.cpp:1.6
--- netpanzer/src/NetPanzer/Classes/UnitPowerUp.cpp:1.5 Wed Sep 10 08:32:53 2003
+++ netpanzer/src/NetPanzer/Classes/UnitPowerUp.cpp     Sat Sep 13 18:38:21 2003
@@ -163,7 +163,7 @@
   UnitBase *unit;
   PlayerID player_id;
   
-  sound->PlayPowerUpSound();
+  sound->playPowerUpSound();
 
   unit = UnitInterface::getUnit( unit_id );
   
@@ -276,7 +276,7 @@
  {
   PlayerID local_player_id;
 
-  sound->PlayPowerUpSound(); 
+  sound->playPowerUpSound(); 
   powerup_state.life_cycle_state = _power_up_lifecycle_state_inactive; 
   
   local_player_id = PlayerInterface::getLocalPlayerID();
Index: netpanzer/src/NetPanzer/Classes/Units/Abrams.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Abrams.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/Abrams.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/Abrams.cpp:1.4        Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Abrams.cpp    Sat Sep 13 18:38:21 2003
@@ -16,12 +16,13 @@
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 #include <config.h>
+
 #include "Abrams.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -77,29 +78,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
-   
-
  }
 
-void  Abrams::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short Abrams::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 3, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("ht-fire", distance );
+       sound->playBattle();
 
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       return Weapon::_shell;
+}
+//-----------------------------------------------------------------
+void Abrams::soundSelected()
+{
+       sound->playSound("ht-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/Abrams.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Abrams.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/Abrams.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/Abrams.hpp:1.2        Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Abrams.hpp    Sat Sep 13 18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    Abrams( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/Archer.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Archer.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/Archer.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/Archer.cpp:1.4        Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Archer.cpp    Sat Sep 13 18:38:21 2003
@@ -18,10 +18,10 @@
 #include <config.h>
 #include "Archer.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -75,28 +75,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
- 
  }
 
-void  Archer::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short Archer::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 4, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
-
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("mu-fire", distance );
+       sound->playBattle();
+
+       return Weapon::_double_missile;
+}
+//-----------------------------------------------------------------
+void Archer::soundSelected()
+{
+       sound->playSound("mu-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/Archer.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Archer.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/Archer.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/Archer.hpp:1.2        Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Archer.hpp    Sat Sep 13 18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    Archer( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/Hammerhead.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Hammerhead.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/Hammerhead.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/Hammerhead.cpp:1.4    Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Hammerhead.cpp        Sat Sep 13 
18:38:21 2003
@@ -18,10 +18,10 @@
 #include <config.h>
 #include "Hammerhead.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -75,28 +75,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
- 
  }
 
-void  Hammerhead::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short Hammerhead::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 1, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
-
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("mu-fire", distance );
+       sound->playBattle();
+
+       return Weapon::_quad_missile;
+}
+//-----------------------------------------------------------------
+void Hammerhead::soundSelected()
+{
+       sound->playSound("mu-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/Hammerhead.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Hammerhead.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/Hammerhead.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/Hammerhead.hpp:1.2    Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Hammerhead.hpp        Sat Sep 13 
18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    Hammerhead( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/Humvee.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Humvee.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/Humvee.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/Humvee.cpp:1.4        Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Humvee.cpp    Sat Sep 13 18:38:21 2003
@@ -18,16 +18,15 @@
 #include <config.h>
 #include "Humvee.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 #include "GameConfig.hpp"
 
 #include "UnitGlobals.hpp"
 
 // NOTE: Temp unit new sprites put in 
-#include "WorldViewInterface.hpp"
 #include "DDHardSurface.hpp"
 
 void Humvee::setUnitProperties( void )
@@ -105,28 +104,19 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
-
  }
 
-void  Humvee::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short Humvee::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 3, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("lt-fire", distance );
+       sound->playBattle();
 
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       return Weapon::_shell;
 }
Index: netpanzer/src/NetPanzer/Classes/Units/Humvee.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Humvee.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/Humvee.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/Humvee.hpp:1.2        Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Humvee.hpp    Sat Sep 13 18:38:21 2003
@@ -24,8 +24,7 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
-   
+   virtual unsigned short launchProjectile();
 
   public:
    Humvee( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/Leopard.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Leopard.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/Leopard.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/Leopard.cpp:1.4       Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Leopard.cpp   Sat Sep 13 18:38:21 2003
@@ -18,10 +18,10 @@
 #include <config.h>
 #include "Leopard.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -77,28 +77,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
-
  }
 
-void  Leopard::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short Leopard::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 3, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
-
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("mt-fire", distance );
+       sound->playBattle();
+
+       return Weapon::_shell;
+}
+//-----------------------------------------------------------------
+void Leopard::soundSelected()
+{
+       sound->playSound("mt-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/Leopard.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Leopard.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/Leopard.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/Leopard.hpp:1.2       Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Leopard.hpp   Sat Sep 13 18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    Leopard( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/Lynx.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Lynx.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/Lynx.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/Lynx.cpp:1.4  Wed Sep 10 08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Lynx.cpp      Sat Sep 13 18:38:21 2003
@@ -18,10 +18,10 @@
 #include <config.h>
 #include "Lynx.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -77,28 +77,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
-
  }
 
-void  Lynx::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short Lynx::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 3, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("lt-fire", distance );
+       sound->playBattle();
 
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       return Weapon::_shell;
+}
+//-----------------------------------------------------------------
+void Lynx::soundSelected()
+{
+       sound->playSound("lt-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/Lynx.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Lynx.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/Lynx.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/Lynx.hpp:1.2  Wed Sep 10 08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Lynx.hpp      Sat Sep 13 18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    Lynx( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/M109.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/M109.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/M109.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/M109.cpp:1.4  Wed Sep 10 08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/M109.cpp      Sat Sep 13 18:38:21 2003
@@ -18,10 +18,10 @@
 #include <config.h>
 #include "M109.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -76,28 +76,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
-
  }
 
-void  M109::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short M109::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 3, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("ht-fire", distance );
+       sound->playBattle();
 
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       return Weapon::_shell;
+}
+//-----------------------------------------------------------------
+void M109::soundSelected()
+{
+       sound->playSound("ht-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/M109.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/M109.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/M109.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/M109.hpp:1.2  Wed Sep 10 08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/M109.hpp      Sat Sep 13 18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    M109( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/Scorpion.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Scorpion.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/Scorpion.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/Scorpion.cpp:1.4      Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Scorpion.cpp  Sat Sep 13 18:38:21 2003
@@ -18,10 +18,10 @@
 #include <config.h>
 #include "Scorpion.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -76,28 +76,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
-
  }
 
-void  Scorpion::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short Scorpion::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 3, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("lt-fire", distance );
+       sound->playBattle();
 
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       return Weapon::_shell;
+}
+//-----------------------------------------------------------------
+void Scorpion::soundSelected()
+{
+       sound->playSound("lt-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/Scorpion.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Scorpion.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/Scorpion.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/Scorpion.hpp:1.2      Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Scorpion.hpp  Sat Sep 13 18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    Scorpion( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.cpp:1.5 
netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.cpp:1.6
--- netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.cpp:1.5    Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.cpp        Sat Sep 13 
18:38:21 2003
@@ -19,10 +19,10 @@
 
 #include "SpahPanzer.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -78,28 +78,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
-
  }
 
-void  SpahPanzer::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short SpahPanzer::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 3, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("mt-fire", distance );
+       sound->playBattle();
 
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       return Weapon::_shell;
+}
+//-----------------------------------------------------------------
+void SpahPanzer::soundSelected()
+{
+       sound->playSound("mt-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.hpp:1.2    Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/SpahPanzer.hpp        Sat Sep 13 
18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    SpahPanzer( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/Valentine.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Valentine.cpp:1.4 
netpanzer/src/NetPanzer/Classes/Units/Valentine.cpp:1.5
--- netpanzer/src/NetPanzer/Classes/Units/Valentine.cpp:1.4     Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Valentine.cpp Sat Sep 13 18:38:21 2003
@@ -18,10 +18,10 @@
 #include <config.h>
 #include "Valentine.hpp"
 #include "UnitProfileInterface.hpp"
-#include "Gdatstct.hpp"
 #include "Color.hpp"
-#include "ProjectileInterface.hpp"
-#include "NetworkState.hpp"
+#include "WorldViewInterface.hpp"
+#include "Weapon.hpp"
+#include "Sound.hpp"
 
 #include "UnitGlobals.hpp"
 
@@ -78,28 +78,24 @@
   body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); 
   body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) );
-
-  //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag );
-  //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag );
-
  }
 
-void  Valentine::fireWeapon( iXY &target_loc )
+//-----------------------------------------------------------------
+/**
+ * Make noise.
+ * @return projectile_type
+ */
+unsigned short Valentine::launchProjectile()
 {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 3, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
-
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcode( &fire_opcode );
-   }
+       //SFX
+       long distance = 
WorldViewInterface::getCameraDistance(unit_state.location);
+       sound->playAmbientSound("lt-fire", distance );
+       sound->playBattle();
+
+       return Weapon::_shell;
+}
+//-----------------------------------------------------------------
+void Valentine::soundSelected()
+{
+       sound->playSound("lt-selected");
 }
Index: netpanzer/src/NetPanzer/Classes/Units/Valentine.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Valentine.hpp:1.2 
netpanzer/src/NetPanzer/Classes/Units/Valentine.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/Units/Valentine.hpp:1.2     Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Valentine.hpp Sat Sep 13 18:38:21 2003
@@ -24,7 +24,8 @@
  {
   protected:
    void setUnitProperties( void );
-   virtual void  fireWeapon( iXY &target_loc );
+   virtual unsigned short launchProjectile();
+   virtual void soundSelected();
  
   public:
    Valentine( iXY initial_loc, unsigned char color, unsigned char flag );
Index: netpanzer/src/NetPanzer/Classes/Units/Vehicle.cpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Vehicle.cpp:1.5 
netpanzer/src/NetPanzer/Classes/Units/Vehicle.cpp:1.6
--- netpanzer/src/NetPanzer/Classes/Units/Vehicle.cpp:1.5       Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Vehicle.cpp   Sat Sep 13 18:38:21 2003
@@ -23,11 +23,10 @@
 #include "MapInterface.hpp"
 #include "PathScheduler.hpp"
 #include "ProjectileInterface.hpp"
-
 #include "NetworkState.hpp"
+#include "Sound.hpp"
 
 // NOTE: Temp unit new sprites put in 
-#include "WorldViewInterface.hpp"
 #include "DDHardSurface.hpp"
 #include "GameConfig.hpp"
 
@@ -1523,24 +1522,33 @@
  }
 
 void Vehicle::fireWeapon( iXY &target_loc )
- {
-  reload_counter = 0;
-  ProjectileInterface::newProjectile( 0, unit_state.unit_type, unit_id, 
unit_state.damage_factor, 
-                                      unit_state.location, 
-                                      target_loc
-                                     );
+{
+       reload_counter = 0;
 
-  if ( NetworkState::status == _network_state_server )
-   {
-    FireWeaponOpcode fire_opcode;
-    fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
-    fire_opcode.unit_index = unit_id.getIndex();
-       fire_opcode.player_index = unit_id.getPlayer();
-    fire_opcode.x = target_loc.x;
-    fire_opcode.y = target_loc.y;    
-    sendOpcodeNG( &fire_opcode );
-   }
- } 
+       unsigned short projectile_type = launchProjectile();
+       ProjectileInterface::newProjectile(projectile_type, 
unit_state.unit_type, unit_id,
+                       unit_state.damage_factor,
+                       unit_state.location,
+                       target_loc
+                       );
+
+       if ( NetworkState::status == _network_state_server )
+       {
+               FireWeaponOpcode fire_opcode;
+               fire_opcode.opcode = _UNIT_OPCODE_FIRE_WEAPON;
+               fire_opcode.unit_index = unit_id.getIndex();
+               fire_opcode.player_index = unit_id.getPlayer();
+               fire_opcode.x = target_loc.x;
+               fire_opcode.y = target_loc.y;
+               sendOpcodeNG( &fire_opcode );
+       }
+}
+
+//-----------------------------------------------------------------
+void Vehicle::soundSelected()
+{
+       sound->playSound("yessir");
+}
 
 void Vehicle::accessThreatLevels( void )
  {
Index: netpanzer/src/NetPanzer/Classes/Units/Vehicle.hpp
diff -u netpanzer/src/NetPanzer/Classes/Units/Vehicle.hpp:1.3 
netpanzer/src/NetPanzer/Classes/Units/Vehicle.hpp:1.4
--- netpanzer/src/NetPanzer/Classes/Units/Vehicle.hpp:1.3       Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Units/Vehicle.hpp   Sat Sep 13 18:38:21 2003
@@ -202,8 +202,9 @@
   iXY aiFsmManualMove_prev_loc;
   void aiFsmManualMove( void );
    
-  virtual void fireWeapon( iXY &target_loc );
-
+  void fireWeapon( iXY &target_loc );
+  virtual unsigned short launchProjectile() = 0;
+  virtual void soundSelected();
   
   TimerFrameBase threat_level_under_attack_timer;
   void accessThreatLevels( void );
Index: netpanzer/src/NetPanzer/Classes/Weapons/BulletWeapon.cpp
diff -u netpanzer/src/NetPanzer/Classes/Weapons/BulletWeapon.cpp:1.6 
netpanzer/src/NetPanzer/Classes/Weapons/BulletWeapon.cpp:1.7
--- netpanzer/src/NetPanzer/Classes/Weapons/BulletWeapon.cpp:1.6        Wed Sep 
10 08:46:55 2003
+++ netpanzer/src/NetPanzer/Classes/Weapons/BulletWeapon.cpp    Sat Sep 13 
18:38:21 2003
@@ -86,9 +86,8 @@
                                lifecycle_status = _lifecycle_weapon_in_active;
 
                                //SFX
-                               sound->PlayAmbientSound( _not_applicable, 
-                                                                               
 Sound::_hit_target, 
-                                                                               
 WorldViewInterface::getCameraDistance( location ) );
+                               sound->playAmbientSound("hit",
+                                               
WorldViewInterface::getCameraDistance( location ) );
 
                                // **  Particle Shit
                                iXY loc = iXY( location.x, location.y );
Index: netpanzer/src/NetPanzer/Classes/Weapons/MissleWeapon.cpp
diff -u netpanzer/src/NetPanzer/Classes/Weapons/MissleWeapon.cpp:1.6 
netpanzer/src/NetPanzer/Classes/Weapons/MissleWeapon.cpp:1.7
--- netpanzer/src/NetPanzer/Classes/Weapons/MissleWeapon.cpp:1.6        Wed Sep 
10 08:46:55 2003
+++ netpanzer/src/NetPanzer/Classes/Weapons/MissleWeapon.cpp    Sat Sep 13 
18:38:21 2003
@@ -135,9 +135,8 @@
                                lifecycle_status = _lifecycle_weapon_in_active;
 
                                //SFX
-                               sound->PlayAmbientSound( _not_applicable, 
-                                                                               
 Sound::_hit_target, 
-                                                                               
 WorldViewInterface::getCameraDistance( location ) );
+                               sound->playAmbientSound("hit",
+                                               
WorldViewInterface::getCameraDistance( location ) );
 
                                // **  Particle Shit
                                ParticleInterface::addMiss(location, 
Weapon::owner_type_id);
Index: netpanzer/src/NetPanzer/Classes/Weapons/ShellWeapon.cpp
diff -u netpanzer/src/NetPanzer/Classes/Weapons/ShellWeapon.cpp:1.6 
netpanzer/src/NetPanzer/Classes/Weapons/ShellWeapon.cpp:1.7
--- netpanzer/src/NetPanzer/Classes/Weapons/ShellWeapon.cpp:1.6 Wed Sep 10 
08:46:55 2003
+++ netpanzer/src/NetPanzer/Classes/Weapons/ShellWeapon.cpp     Sat Sep 13 
18:38:21 2003
@@ -109,9 +109,8 @@
                                lifecycle_status = _lifecycle_weapon_in_active;
 
                                //SFX
-                               sound->PlayAmbientSound( _not_applicable, 
-                                                                               
 Sound::_hit_target, 
-                                                                               
 WorldViewInterface::getCameraDistance( location ) );
+                               sound->playAmbientSound("hit",
+                                               
WorldViewInterface::getCameraDistance( location ) );
 
                                // **  Particle Shit
                                iXY loc = iXY( location.x, location.y );
Index: netpanzer/src/NetPanzer/Classes/Weapons/Weapon.hpp
diff -u netpanzer/src/NetPanzer/Classes/Weapons/Weapon.hpp:1.3 
netpanzer/src/NetPanzer/Classes/Weapons/Weapon.hpp:1.4
--- netpanzer/src/NetPanzer/Classes/Weapons/Weapon.hpp:1.3      Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Classes/Weapons/Weapon.hpp  Sat Sep 13 18:38:21 2003
@@ -41,6 +41,18 @@
 
 class Weapon : public Projectile
 {
+public:
+       /**
+        * Projectile types.
+        */
+       enum {
+               _none,
+               _quad_missile,
+               _bullet,
+               _shell,
+               _double_missile
+       };
+
 protected:
        SpritePacked shell;
        SpritePacked shellShadow;
Index: netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp
diff -u netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.11 
netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.12
--- netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.11     Thu Sep 
11 13:35:47 2003
+++ netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp  Sat Sep 13 
18:38:21 2003
@@ -675,13 +675,14 @@
           current_selection_list_index = 0xFFFF;
           if ( working_list.unit_list.containsItems() > 0 )
            {
-            sound->PlayUnitVoice( working_list.getHeadUnitType(), 
-                                                                 
Sound::_selected);
+                          UnitBase *unit = 
UnitInterface::getUnit(working_list.unit_list[0]);
+                          unit->soundSelected();
            }
 
             } break; 
 
            case _cursor_move:
+           case _cursor_blocked:
             {
           sendMoveCommand( world_pos );
             } break;
@@ -815,8 +816,8 @@
    } // ** if 
 
   //sfx
-  sound->PlayUnitSound(working_list.getHeadUnitType() );
-  sound->PlayUnitVoice(working_list.getHeadUnitType(), Sound::_move_to);  
+  sound->playUnitSound(working_list.getHeadUnitType() );
+  sound->playSound("move");
  }
 
 void WorldInputCmdProcessor::sendAttackCommand( iXY &world_pos )
@@ -871,7 +872,7 @@
      } // ** if 
 
     //sfx 
-    sound->PlayUnitVoice(working_list.getHeadUnitType(), Sound::_target_enemy);
+    sound->playSound("target");
    } // ** if 
  }
 
@@ -963,7 +964,7 @@
       CLIENT->sendMessage( encode_message, encode_message->realSize(), 0 );   
      } // ** if 
     // SFX
-    sound->PlayUnitVoice(working_list.getHeadUnitType(), Sound::_target_enemy);
+    sound->playSound("target");
    } // ** if containsItems() > 0  
 
  }
Index: netpanzer/src/NetPanzer/Core/main.cpp
diff -u netpanzer/src/NetPanzer/Core/main.cpp:1.5 
netpanzer/src/NetPanzer/Core/main.cpp:1.6
--- netpanzer/src/NetPanzer/Core/main.cpp:1.5   Fri Sep 12 20:37:03 2003
+++ netpanzer/src/NetPanzer/Core/main.cpp       Sat Sep 13 18:38:21 2003
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
+#include <ctype.h>
 #include <SDL.h>
 
 #include <optionmm/command_line.hpp>
@@ -80,11 +81,7 @@
                        {
                                
KeyboardInterface::keyPressed(event.key.keysym.sym);
                                char c = event.key.keysym.unicode & 0x7F;
-                               // XXX This is not optimal... we should find 
another way to
-                               // differentiate normal chars and special 
keys...
-                               if ( (c >= 'a' && c <= 'z') || (c >= '0' && 
c<='9')
-                                       || (c>= 'A' && c <= 'Z') || c == '_' || 
c=='.'
-                                       || c==' ') {
+                               if (isprint(c)) {
                                        KeyboardInterface::putChar(c);
                                } else {
                                        // it's not a normal char put the 0 
into the char buffer to
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.37 
netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.38
--- netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.37     Fri Sep 12 
17:37:10 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.cpp  Sat Sep 13 18:38:21 2003
@@ -375,7 +375,6 @@
        
        Palette pal;
 
-//     Screen->palette.loadLibPalette(pal, Screen->lpFrontBuffer);
        Screen->setPalette(pal.color);
  }
 
@@ -1006,7 +1005,7 @@
 {
   iXY spawn_point;
 
-  sound->StopTankIdle(); 
+  sound->stopTankIdle(); 
   
   // ** Get a new spawn point and spawn the player ** 
   MapInterface::getFreeSpawnPoint( &spawn_point );
@@ -1027,7 +1026,7 @@
     SERVER->sendMessage( player, &set_view, sizeof( SystemSetPlayerView ), 0);
    }
   
-  sound->PlayTankIdle();
+  sound->playTankIdle();
 }     
 
 void GameManager::respawnAllPlayers()
@@ -1577,7 +1576,7 @@
 #endif
 
   ClientConnectDaemon::startConnectionProcess();
-  sound->PlayTankIdle();
+  sound->playTankIdle();
  }
 
 // ******************************************************************
@@ -1759,7 +1758,7 @@
 void GameManager::exitNetPanzer()
 {
        // NOTE: Hack
-       sound->StopTankIdle(); 
+       sound->stopTankIdle(); 
 
        quitNetPanzerGame();
 
Index: netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp:1.9 
netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp:1.10
--- netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp:1.9   Fri Sep 12 
20:15:08 2003
+++ netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp       Sat Sep 13 
18:38:21 2003
@@ -262,6 +262,8 @@
 
 void MouseInterface::setCursor(CursorType type)
 {
+       
+       
        switch(type)
        {
     case defaultcursor:
Index: netpanzer/src/NetPanzer/Interfaces/MouseInterface.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/MouseInterface.hpp:1.6 
netpanzer/src/NetPanzer/Interfaces/MouseInterface.hpp:1.7
--- netpanzer/src/NetPanzer/Interfaces/MouseInterface.hpp:1.6   Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Interfaces/MouseInterface.hpp       Sat Sep 13 
18:38:21 2003
@@ -18,6 +18,8 @@
 #ifndef _MOUSEINTERFACE_HPP
 #define _MOUSEINTERFACE_HPP
 
+#include <string>
+#include <vector>
 #include "QueueTemplate.hpp"
 #include "Surface.hpp"
 
@@ -50,7 +52,14 @@
        static Surface mouse_cursor;
        static unsigned char cursor_x_size;
        static unsigned char cursor_y_size;
-  
+
+       struct MouseCursorEntry
+       {
+               std::string name;
+               Surface cursor;
+       };
+       std::vector<MouseCursorEntry> cursors;
+
 protected:
        static iXY mouse_pos;  
    
@@ -100,29 +109,28 @@
                *y = mouse_pos.y;
        }
  
-   static inline unsigned char getButtonMask( void )
+   static inline unsigned char getButtonMask()
     {
      return( button_mask );
     }
      
    static bool buttonHeld( unsigned char mask);
-   static void resetButtonHoldStatus( void );
+   static void resetButtonHoldStatus();
    
-   static void setLeftButtonDown( void );
-   static void setLeftButtonUp( void );
-   static void setLeftButtonDoubleDown( void );
+   static void setLeftButtonDown();
+   static void setLeftButtonUp();
+   static void setLeftButtonDoubleDown();
          
-   static void setRightButtonDown( void );
-   static void setRightButtonUp( void );
-   static void setRightButtonDoubleDown( void );
-
-   static void setMiddleButtonDown( void );
-   static void setMiddleButtonUp( void );
-   static void setMiddleButtonDoubleDown( void );
-   
-   static void setCursor(CursorType type);
-    
-   static void updateCursor( void );
+   static void setRightButtonDown();
+   static void setRightButtonUp();
+   static void setRightButtonDoubleDown();
+
+   static void setMiddleButtonDown();
+   static void setMiddleButtonUp();
+   static void setMiddleButtonDoubleDown();
+   
+   static void setCursor(CursorType type); 
+   static void updateCursor();
 };
 
 #endif // ** _MOUSEINTERFACE_HPP
Index: netpanzer/src/NetPanzer/Interfaces/ProjectileInterface.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/ProjectileInterface.cpp:1.5 
netpanzer/src/NetPanzer/Interfaces/ProjectileInterface.cpp:1.6
--- netpanzer/src/NetPanzer/Interfaces/ProjectileInterface.cpp:1.5      Wed Sep 
10 08:32:54 2003
+++ netpanzer/src/NetPanzer/Interfaces/ProjectileInterface.cpp  Sat Sep 13 
18:38:21 2003
@@ -18,8 +18,6 @@
 #include <config.h>
 #include "ProjectileInterface.hpp"
 
-#include "Sound.hpp"
-
 #include "ParticleInterface.hpp"
 #include "MissleWeapon.hpp"
 #include "BulletWeapon.hpp"
@@ -74,15 +72,11 @@
  {
   Projectile *temp;
 
-  if (projectile_type == 0)
+  if (projectile_type == Weapon::_none)
   {
-         temp = new Weapon( owner, owner_type_id, damage, start, end );
-         
-         // We should make sure and customize all these.
-         temp->addToList( &projectile_list_start, &projectile_list_end );
          assert(false);
   }
-  else if (projectile_type == 1)
+  else if (projectile_type == Weapon::_quad_missile)
   {
          // The following code launches 4 missles spaced out evenly like they 
would be in a
          // missle bay.
@@ -128,19 +122,19 @@
          temp->addToList( &projectile_list_start, &projectile_list_end );
          ParticleInterface::addMissleLaunchPuff(startPos, direction, 
owner_type_id);
   }
-  else if (projectile_type == 2)
+  else if (projectile_type == Weapon::_bullet)
   {
          temp = new BulletWeapon( owner, owner_type_id, damage, start, end );
          temp->addToList( &projectile_list_start, &projectile_list_end );
   }
-  else if (projectile_type == 3)
+  else if (projectile_type == Weapon::_shell)
   {
          temp = new ShellWeapon( owner, owner_type_id, damage, start, end );
          temp->addToList( &projectile_list_start, &projectile_list_end );
   }
-  else if (projectile_type == 4)
+  else if (projectile_type == Weapon::_double_missile)
   {
-         // The following code launches 4 missles spaced out evenly like they 
would be in a
+         // The following code launches 2 missles spaced out evenly like they 
would be in a
          // missle bay.
          iXY startPos;
          iXY endPos;
@@ -184,15 +178,6 @@
          //temp->addToList( &projectile_list_start, &projectile_list_end );
          //ParticleInterface::addMissleLaunchPuff(startPos, direction, 
owner_type_id);
   }
-  
-  //assert( temp != 0 );
-
-  //temp->addToList( &projectile_list_start, &projectile_list_end );
-  
-  //SFX
-  long distance = WorldViewInterface::getCameraDistance( start );
-  sound->PlayAmbientSound( owner_type_id, Sound::_fire_gun, distance );
-  sound->PlayAmbientSound( _not_applicable, Sound::_random_battle, distance );
  }
 
 
Index: netpanzer/src/NetPanzer/Interfaces/UnitInterface.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/UnitInterface.cpp:1.6 
netpanzer/src/NetPanzer/Interfaces/UnitInterface.cpp:1.7
--- netpanzer/src/NetPanzer/Interfaces/UnitInterface.cpp:1.6    Wed Sep 10 
08:32:54 2003
+++ netpanzer/src/NetPanzer/Interfaces/UnitInterface.cpp        Sat Sep 13 
18:38:21 2003
@@ -207,9 +207,8 @@
                ParticleInterface::addHit(unit->unit_state);
     
                //SFX
-        sound->PlayAmbientSound( _not_applicable, 
-                                                                
Sound::_blow_up_tank,
-                                                                
WorldViewInterface::getCameraDistance( unit->unit_state.location ) );
+               sound->playAmbientSound("expl",
+                               WorldViewInterface::getCameraDistance( 
unit->unit_state.location ) );
 
         deleteUnit( unit );                              
        }
@@ -1035,9 +1034,8 @@
     ParticleInterface::addHit(unit->unit_state);
 
     //SFX
-    sound->PlayAmbientSound( _not_applicable, 
-                                                        Sound::_blow_up_tank,
-                                                    
WorldViewInterface::getCameraDistance( unit->unit_state.location ) );
+       sound->playAmbientSound("expl",
+                       WorldViewInterface::getCameraDistance( 
unit->unit_state.location ) );
 
     unit_lists[ unit_id.getPlayer() ].deleteUnit( unit_id );
    }
Index: netpanzer/src/NetPanzer/Port/Gdatstct.cpp
diff -u netpanzer/src/NetPanzer/Port/Gdatstct.cpp:1.4 
netpanzer/src/NetPanzer/Port/Gdatstct.cpp:1.5
--- netpanzer/src/NetPanzer/Port/Gdatstct.cpp:1.4       Sat Sep  6 14:59:06 2003
+++ netpanzer/src/NetPanzer/Port/Gdatstct.cpp   Sat Sep 13 18:38:21 2003
@@ -22,11 +22,17 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+
 #include "Globals.h"
 #include "Log.hpp"
 #include "Exception.hpp"
 
-sprite_dbase FLAGS_DBASE;
+// XXX remember to remove this later
+#if 1
+#include <SDL.h>
+#include "Palette.hpp"
+#include "String.hpp"
+#endif
 
 //*****************************************************************************
 sprite_dbase::sprite_dbase( void )
@@ -88,9 +94,9 @@
   fclose( infile );
 
   dbase_loaded = true;
+
   return( true ); 
- }
- 
+}
 
 //*****************************************************************************
 
Index: netpanzer/src/NetPanzer/Port/Gdatstct.hpp
diff -u netpanzer/src/NetPanzer/Port/Gdatstct.hpp:1.3 
netpanzer/src/NetPanzer/Port/Gdatstct.hpp:1.4
--- netpanzer/src/NetPanzer/Port/Gdatstct.hpp:1.3       Mon Sep  8 08:12:19 2003
+++ netpanzer/src/NetPanzer/Port/Gdatstct.hpp   Sat Sep 13 18:38:21 2003
@@ -37,20 +37,19 @@
        unsigned char *data;
 };
 
-//****************************************************************************************
+//***************************************************************************
 
-typedef
- struct
-  {
-   char  name[32];  // name of sprite -- default file from which it was 
extracted
-   short pyro_id;   // pryosoft id #
-   short x_size;    // width of animation frame in pixels
-   short y_size;    // height of animation frame in pixels
-
-   short g_attrib;    // sprite attributes
-                      // bit 0 = standard pic
-                      // bit 1 = transparent 
-                      // bit 2 = shadowed 
+struct animation_data
+{
+       char  name[32];  // name of sprite -- default file from which it was 
extracted
+       short pyro_id;   // pryosoft id #
+       short x_size;    // width of animation frame in pixels
+       short y_size;    // height of animation frame in pixels
+
+       short g_attrib;    // sprite attributes
+                                          // bit 0 = standard pic
+                                          // bit 1 = transparent 
+                                          // bit 2 = shadowed 
 
    unsigned char anim_type;   // type of animations
                       // bit 0 = standard multiframe animation;
@@ -70,26 +69,23 @@
    unsigned char *directions[76];  
    
    unsigned char *data;
-                   
-  } animation_data;
+};
 
-//****************************************************************************************
+//***************************************************************************
 
- typedef
-  struct
-   {
+struct tile_info_type
+{
     unsigned char t_attrib; // tile attributes
                     // bits 0-3 height value of terrain
                     // bits 4-7 reserved
                     
     unsigned char move_val; //movement value for tile
-   } tile_info_type;
+};
 
-//****************************************************************************************
+//***************************************************************************
    
- typedef
-  struct
-   {
+struct tile_dbase_header_type
+{
     char  pyro_id_header[64]; // file text identification;
     short pyro_tile_set_id;   // internal tile set identification;
     short tile_x_size;        // x_size of tile in pixels
@@ -97,50 +93,46 @@
     short tile_size;          // tile size in bytes
     short tile_count;         // tile_count;
     unsigned char palette[768];       // pallette for tileset;
-    
-   } tile_dbase_header_type;
+};
 
-//****************************************************************************************
+//***************************************************************************
 
- typedef
-  struct
-   {
+struct sprite_dbase_header_type
+{
     char  pyro_id_header[64]; // file text identification;
     short pyro_sprite_dbs_id;   // internal tile set identification;
     short sprite_count;
-   } sprite_dbase_header_type;
+};
 
-//****************************************************************************************
+//***************************************************************************
 
- typedef
-  struct
-   {
-    char  pyro_id_header[64]; // file text identification;
-    short pyro_anim_dbs_id;   // internal tile set identification;
-    short animation_count;
-   } anim_dbase_header_type;
+struct anim_dbase_header_type
+{
+       char  pyro_id_header[64]; // file text identification;
+       short pyro_anim_dbs_id;   // internal tile set identification;
+       short animation_count;
+};
 
-//****************************************************************************************
+//***************************************************************************
 
 class sprite_dbase
- { 
-  public: 
-   short dbase_loaded; 
-   sprite_dbase_header_type header;
-   sprite_data sprite_list[255];
+{ 
+public: 
+       short dbase_loaded; 
+       sprite_dbase_header_type header;
+       sprite_data sprite_list[255];
  
-  sprite_dbase( void );
-  short load_dbase( char *dbase_path );
-  short unload_dbase( void );
-  short get_sprite_index( short index, sprite_data *record );
-  short get_sprite_id( short id_num, sprite_data *record );
-  short get_sprite_name( char *name, sprite_data *record ); 
-  short get_sprite_name( char *name, Surface &surface ); 
-  short get_sprite_index( short index, Surface &surface );
-
- } ;
+       sprite_dbase( void );
+       short load_dbase( char *dbase_path );
+       short unload_dbase( void );
+       short get_sprite_index( short index, sprite_data *record );
+       short get_sprite_id( short id_num, sprite_data *record );
+       short get_sprite_name( char *name, sprite_data *record ); 
+       short get_sprite_name( char *name, Surface &surface ); 
+       short get_sprite_index( short index, Surface &surface );
+};
 
-//****************************************************************************************
+//***************************************************************************
 
 class animation_dbase
  {
@@ -162,17 +154,15 @@
 
 
 class tile_dbase
- {
-  public:
-  short dbase_loaded; 
-  tile_dbase_header_type header;
-  unsigned char *tile_data;
+{
+public:
+       short dbase_loaded; 
+       tile_dbase_header_type header;
+       unsigned char *tile_data;
   
-  tile_dbase( void ); 
-  short load_dbase( char *dbase_path );
-  short unload_dbase( void ); 
- };
-
-extern sprite_dbase FLAGS_DBASE;
+       tile_dbase( void ); 
+       short load_dbase( char *dbase_path );
+       short unload_dbase( void ); 
+};
 
 #endif
Index: netpanzer/src/NetPanzer/Port/Globals.h
diff -u netpanzer/src/NetPanzer/Port/Globals.h:1.2 
netpanzer/src/NetPanzer/Port/Globals.h:1.3
--- netpanzer/src/NetPanzer/Port/Globals.h:1.2  Mon Sep  1 16:24:21 2003
+++ netpanzer/src/NetPanzer/Port/Globals.h      Sat Sep 13 18:38:21 2003
@@ -18,6 +18,7 @@
 #ifndef _GLOBALS_H
 #define _GLOBALS_H
 
+#if 0
 extern short DISPLAY_PAGE_STATE;
 
 //short CURRENT_BANK;
@@ -28,8 +29,6 @@
 //unsigned long WORLD_WIDTH =  2560;
 //unsigned long WORLD_HEIGHT = 2720;
 
-extern unsigned char *TILE_DATA;
-
 extern unsigned char *INTERFACE_BUFFER;
 
 //#############################################################################
@@ -41,15 +40,8 @@
 extern long SCREEN_X_BOUND,SCREEN_Y_BOUND;
 
 //byte SCROLL_LEFT,SCROLL_RIGHT,SCROLL_UP,SCROLL_DOWN;
+#endif
 
-extern int GAME_STATE_PAUSED;
-
-enum { _network_state_server, _network_state_client };
-
-extern int NETWORK_STATE; 
-
-extern int maxplayers;
-extern int dedicated;
+extern unsigned char *TILE_DATA;
 
-enum { _640x480_v48x48 , _640x480_v64x48, _800x600_v80x60 };
 #endif
Index: netpanzer/src/NetPanzer/Views/Game/AreYouSureResignView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/AreYouSureResignView.cpp:1.8 
netpanzer/src/NetPanzer/Views/Game/AreYouSureResignView.cpp:1.9
--- netpanzer/src/NetPanzer/Views/Game/AreYouSureResignView.cpp:1.8     Wed Sep 
10 07:26:10 2003
+++ netpanzer/src/NetPanzer/Views/Game/AreYouSureResignView.cpp Sat Sep 13 
18:38:21 2003
@@ -34,7 +34,7 @@
 //---------------------------------------------------------------------------
 static void bYES()
 {
-       sound->StopTankIdle();
+       sound->stopTankIdle();
 
        GameManager::drawTextCenteredOnScreen("Loading Main View...", 
Color::white);
 
Index: netpanzer/src/NetPanzer/Views/Game/WinnerMesgView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/WinnerMesgView.cpp:1.7 
netpanzer/src/NetPanzer/Views/Game/WinnerMesgView.cpp:1.8
--- netpanzer/src/NetPanzer/Views/Game/WinnerMesgView.cpp:1.7   Mon Sep  8 
11:32:05 2003
+++ netpanzer/src/NetPanzer/Views/Game/WinnerMesgView.cpp       Sat Sep 13 
18:38:22 2003
@@ -44,7 +44,7 @@
   }
  else
   {  
-    sound->StopTankIdle();
+    sound->stopTankIdle();
 
        // Blank the screen.
 
Index: netpanzer/src/UILib/DummySound.cpp
diff -u netpanzer/src/UILib/DummySound.cpp:1.1 
netpanzer/src/UILib/DummySound.cpp:1.2
--- netpanzer/src/UILib/DummySound.cpp:1.1      Mon Sep  8 17:25:41 2003
+++ netpanzer/src/UILib/DummySound.cpp  Sat Sep 13 18:38:22 2003
@@ -29,39 +29,11 @@
 {
 }
 
-void DummySound::PlayTankIdle()
-{
-}
-
-void DummySound::StopTankIdle()
-{
-}
-
-void DummySound::PlayMenuSound()
-{
-}
-
-void DummySound::PlayAttackWarning()
-{
-}
-
-void DummySound::PlayPowerUpSound()
-{
-}
-
-void DummySound::PlayUnitSound(int )
-{
-}
-
-void DummySound::PlayUnitVoice(int, Event)
-{
-}
-
-void DummySound::PlayAmbientSound(int, Event, long)
+void DummySound::playSound(const char*)
 {
 }
 
-void DummySound::playSound(const char*)
+void DummySound::playAmbientSound(const char*, long)
 {
 }
 
Index: netpanzer/src/UILib/DummySound.hpp
diff -u netpanzer/src/UILib/DummySound.hpp:1.1 
netpanzer/src/UILib/DummySound.hpp:1.2
--- netpanzer/src/UILib/DummySound.hpp:1.1      Mon Sep  8 17:25:41 2003
+++ netpanzer/src/UILib/DummySound.hpp  Sat Sep 13 18:38:22 2003
@@ -27,16 +27,12 @@
        DummySound();
        virtual ~DummySound();
        
-       virtual void PlayTankIdle();
-       virtual void StopTankIdle();
-       virtual void PlayMenuSound();
-       virtual void PlayAttackWarning();
-       virtual void PlayPowerUpSound();
-       virtual void PlayUnitSound(int unit_type);
-       virtual void PlayUnitVoice(int unit_type, Event event);
-       virtual void PlayAmbientSound(int unit_type, Event event, long 
distance);
-
        virtual void playSound(const char* name);
+       virtual void playAmbientSound(const char *name, long distance);
+       virtual int playSoundRepeatedly(const char* name)
+       { return -1; }
+       virtual void stopChannel(int channel)
+       {}
 
        virtual void playMusic(const char* directory);
        virtual void stopMusic();
Index: netpanzer/src/UILib/SDL/SDLSound.cpp
diff -u netpanzer/src/UILib/SDL/SDLSound.cpp:1.5 
netpanzer/src/UILib/SDL/SDLSound.cpp:1.6
--- netpanzer/src/UILib/SDL/SDLSound.cpp:1.5    Fri Sep 12 10:12:45 2003
+++ netpanzer/src/UILib/SDL/SDLSound.cpp        Sat Sep 13 18:38:22 2003
@@ -1,20 +1,21 @@
 /*
-Copyright (C) 2003 Matthias Braun <address@hidden>
-                                                                               
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-                                                                               
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-                                                                               
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
+   Copyright (C) 2003 Matthias Braun <address@hidden>,
+   Ivo Danihelka <address@hidden>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   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 <sys/types.h>
@@ -28,15 +29,24 @@
 #include "Exception.hpp"
 #include "SDLSound.hpp"
 
-SDLSound::SDLSound()
+musics_t SDLSound::musicfiles;
+musics_t::iterator SDLSound::currentsong;
+
+//-----------------------------------------------------------------
+       SDLSound::SDLSound()
+: Sound(), m_chunks()
 {
        if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
                throw Exception("SDL_Init audio error: %s", SDL_GetError());
-               
+
        if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0)
                throw Exception("Couldn't open audio device: %s", 
Mix_GetError());
+
+       loadSound("sound/");
+       Mix_AllocateChannels(16);
 }
 
+//-----------------------------------------------------------------
 SDLSound::~SDLSound()
 {
        stopMusic();
@@ -45,59 +55,176 @@
        SDL_QuitSubSystem(SDL_INIT_AUDIO);
 }
 
-struct SoundEntry
-{
-public:
-       std::string name;
-       std::vector<Mix_Chunk*> sounds;
-};
+//-----------------------------------------------------------------
+/**
+ * Find a chunk for this name.
+ * @param name sound name
+ * @return the chunk or NULL
+ */
+Mix_Chunk *SDLSound::findChunk(const char *name)
+{
+       chunks_t::size_type count = m_chunks.count(name);
+       if (count == 0) {
+               LOG (("Silent sound '%s'", name));
+               return 0;
+       }
 
-void SDLSound::PlayTankIdle()
-{
+       chunks_t::iterator it = m_chunks.find(name);
+       for (int i = rand() % count; i > 0; i--) {
+               it++;
+       }
+       return it->second;
 }
-
-void SDLSound::StopTankIdle()
-{
+//-----------------------------------------------------------------
+/**
+ * Play sound once.
+ * @param name sound name
+ */
+void SDLSound::playSound(const char* name)
+{
+       Mix_Chunk *chunk = findChunk(name);
+       if (chunk) {
+               if (Mix_PlayChannel(-1, chunk, 0) == -1) {
+                       Mix_AllocateChannels(8 + Mix_AllocateChannels(-1));
+                       if (Mix_PlayChannel(-1, chunk, 0) == -1) {
+                               LOG (("Couldn't play sound '%s': %s", name, 
Mix_GetError()));
+                       }
+               }
+       }
 }
-
-void SDLSound::PlayMenuSound()
-{
+//-----------------------------------------------------------------
+/**
+ * Play sound once.
+ * @param name sound name
+ * @param distance mag2 distance
+ */
+void SDLSound::playAmbientSound(const char* name, long distance)
+{
+       Mix_Chunk *chunk = findChunk(name);
+       if (chunk) {
+               int oldVolume = Mix_VolumeChunk(chunk, 
getSoundVolume(distance));
+               if (Mix_PlayChannel(-1, chunk, 0) == -1) {
+                       Mix_AllocateChannels(8 + Mix_AllocateChannels(-1));
+                       if (Mix_PlayChannel(-1, chunk, 0) == -1) {
+                               LOG (("Couldn't play sound '%s': %s", name, 
Mix_GetError()));
+                       }
+               }
+               Mix_VolumeChunk(chunk, oldVolume);
+       }
 }
+//-----------------------------------------------------------------
+/**
+ * Play sound repeatedly.
+ * @param name sound name
+ * @return the channel the sample is played on. On any errors, -1 is returned.
+ */
+int SDLSound::playSoundRepeatedly(const char* name)
+{
+       int channel = -1;
+       Mix_Chunk *chunk = findChunk(name);
+       if (chunk) {
+               if ((channel = Mix_PlayChannel(-1, chunk, -1)) == -1) {
+                       Mix_AllocateChannels(8 + Mix_AllocateChannels(-1));
+                       if ((channel = Mix_PlayChannel(-1, chunk, -1)) == -1) {
+                               LOG (("Couldn't play sound '%s': %s", name, 
Mix_GetError()));
+                       }
+               }
+       }
 
-void SDLSound::PlayAttackWarning()
-{
+       return channel;
 }
-
-void SDLSound::PlayPowerUpSound()
+//-----------------------------------------------------------------
+/**
+ * Stop playing the channel.
+ * @param channel channel to stop
+ */
+       void
+SDLSound::stopChannel(int channel)
 {
+       if (channel != -1) {
+               Mix_HaltChannel(channel);
+       }
 }
-
-void SDLSound::PlayUnitSound(int )
+//-----------------------------------------------------------------
+       int
+SDLSound::getSoundVolume(long distance)
+{
+       //0 to 2 800x600 screen widths away--
+       if( (distance < 640000)) return MIX_MAX_VOLUME;
+
+       //2 to 4 800x600 screen widths away--
+       if( (distance < 10240000)) return int(0.75 * MIX_MAX_VOLUME);
+
+       //4 to 8 800x600 screen widths away--
+       if( (distance < 40960000)) return int(0.5 * MIX_MAX_VOLUME);
+
+       //8 to 12 800x600 screen widths away--
+       if( (distance < 92760000)) return int(0.25 * MIX_MAX_VOLUME);
+
+       //12 to 16 800x600 screen widths away--
+       if( (distance < 163840000)) return int(0.5 * MIX_MAX_VOLUME);
+
+       //anything further away--
+       return 0;
+}
+//-----------------------------------------------------------------
+/**
+ * Load all *.wav from directory.
+ * @param directory path to the directory
+ */
+       void
+SDLSound::loadSound(const char* directory)
 {
-}
+       DIR* dir = opendir(directory);
+       if(!dir) {
+               LOG (("Couldn't scan directory '%s': %s",
+                                       directory, strerror(errno)));
+               return;
+       }
 
-void SDLSound::PlayUnitVoice(int, Event)
-{
-}
+       struct dirent* entry;
+       while( (entry = readdir(dir)) ) {
+               if(entry->d_name[0] == '.')
+                       continue;
 
-void SDLSound::PlayAmbientSound(int, Event, long)
+               std::string filename = directory;
+               filename += entry->d_name;
+               Mix_Chunk *chunk = Mix_LoadWAV(filename.c_str());
+               if (!chunk) {
+                       LOG (("Couldn't load wav '%s': %s",
+                                               filename.c_str(), 
Mix_GetError()));
+               }
+
+               std::string idName = getIdName(entry->d_name);
+               m_chunks.insert(std::pair<std::string,Mix_Chunk *>(idName, 
chunk));
+       }
+       closedir(dir);
+}
+//-----------------------------------------------------------------
+/**
+ * Hash filename to idName.
+ * @return id name
+ */
+       std::string
+SDLSound::getIdName(const char *filename)
 {
+       std::string name = filename;
+       std::string::size_type pos = name.find_first_of("._");
+
+       return name.substr(0, pos);
 }
 
 //---------------------------------------------------------------------------
 // Music part
 //---------------------------------------------------------------------------
 
-std::vector<std::string> SDLSound::musicfiles;
-std::vector<std::string>::iterator SDLSound::currentsong;
-
 void SDLSound::playMusic(const char* directory)
 {
        // Part1: scan directory for music files
        DIR* dir = opendir(directory);
        if(!dir) {
                LOG (("Couldn't scan directory '%s': %s",
-                                               directory, strerror(errno)));
+                                       directory, strerror(errno)));
                return;
        }
 
@@ -106,7 +233,7 @@
        while( (entry = readdir(dir)) ) {
                if(entry->d_name[0] == '.')
                        continue;
-               
+
                std::string filename = directory;
                filename += entry->d_name;
                musicfiles.push_back(filename);
@@ -134,22 +261,29 @@
 
 void SDLSound::nextSong()
 {
+       static Mix_Music *music = 0;
+       if (music != 0) {
+               Mix_HaltMusic();
+               Mix_FreeMusic(music);
+               music = 0;
+       }
+
        if(currentsong == musicfiles.end()) {
                // create a new random playlist
                std::random_shuffle(musicfiles.begin(), musicfiles.end());
                currentsong = musicfiles.begin();
        }
 
-       std::vector<std::string>::iterator lastsong = currentsong;
+       musics_t::iterator lastsong = currentsong;
        do {
                const char* toplay = currentsong->c_str();
-               Mix_Music* music = Mix_LoadMUS(toplay);
+               music = Mix_LoadMUS(toplay);
                currentsong++;
 
                if(music) {
                        if (Mix_PlayMusic(music, 1) == 0) {
                                LOG( ("Start playing song '%s'", toplay) );
-                               break;
+                               break; // break while cycle
                        } else {
                                LOG ( ("Failed to play song '%s': %s", toplay, 
Mix_GetError()));
                        }
@@ -162,4 +296,3 @@
                }
        } while(currentsong != lastsong);
 }
-
Index: netpanzer/src/UILib/SDL/SDLSound.hpp
diff -u netpanzer/src/UILib/SDL/SDLSound.hpp:1.3 
netpanzer/src/UILib/SDL/SDLSound.hpp:1.4
--- netpanzer/src/UILib/SDL/SDLSound.hpp:1.3    Mon Sep  8 08:12:19 2003
+++ netpanzer/src/UILib/SDL/SDLSound.hpp        Sat Sep 13 18:38:22 2003
@@ -20,32 +20,38 @@
 
 #include <string>
 #include <vector>
+#include <map>
+#include <SDL_mixer.h>
 #include "UILib/Sound.hpp"
 
+typedef std::multimap<std::string,Mix_Chunk*> chunks_t;
+typedef std::vector<std::string> musics_t;
+
 class SDLSound : public Sound
 {
 public:
        SDLSound();
        virtual ~SDLSound();
 
-       virtual void PlayTankIdle();
-       virtual void StopTankIdle();
-       virtual void PlayMenuSound();
-       virtual void PlayAttackWarning();
-       virtual void PlayPowerUpSound();
-       virtual void PlayUnitSound(int unit_type);
-       virtual void PlayUnitVoice(int unit_type, Event event);
-       virtual void PlayAmbientSound(int unit_type, Event event, long 
distance);
-       virtual void playSound(const char* name)
-       {}
+       virtual void playSound(const char* name);
+       virtual void playAmbientSound(const char* name, long distance);
+       virtual int playSoundRepeatedly(const char* name);
+       virtual void stopChannel(int channel);
 
        virtual void playMusic(const char* directory);
        virtual void stopMusic();
 
 private:
+       chunks_t m_chunks;
+
+       Mix_Chunk *findChunk(const char *name);
+       int getSoundVolume(long distance);
+       void loadSound(const char* directory);
+       std::string getIdName(const char* filename);
+
        static void nextSong();
-       static std::vector<std::string> musicfiles;
-       static std::vector<std::string>::iterator currentsong;
+       static musics_t musicfiles;
+       static musics_t::iterator currentsong;
 };
 
 #endif
Index: netpanzer/src/UILib/Sound.cpp
diff -u netpanzer/src/UILib/Sound.cpp:1.2 netpanzer/src/UILib/Sound.cpp:1.3
--- netpanzer/src/UILib/Sound.cpp:1.2   Sat Sep  6 18:31:20 2003
+++ netpanzer/src/UILib/Sound.cpp       Sat Sep 13 18:38:22 2003
@@ -19,5 +19,56 @@
 
 #include "Sound.hpp"
 
+#include "UnitTypes.hpp"
+
 Sound* sound = 0;
 
+//-----------------------------------------------------------------
+Sound::Sound()
+{
+       m_battleCount = 0;
+       m_tankIdleChannel = -1;
+}
+//-----------------------------------------------------------------
+/**
+ * Play "tankidle" repeatedly.
+ */
+void Sound::playTankIdle()
+{
+       m_tankIdleChannel = playSoundRepeatedly("tankidle");
+}
+
+void Sound::stopTankIdle()
+{
+       stopChannel(m_tankIdleChannel);
+}
+
+void Sound::playPowerUpSound()
+{
+       playSound("powerup");
+}
+
+void Sound::playUnitSound(int unit_type)
+{
+    if((unit_type == _unit_type_humvee) || (unit_type == 
_unit_type_hover_craft)) {
+               return;
+       }
+       playSound("unitsound");
+}
+
+//-----------------------------------------------------------------
+/**
+ * When many weapons are firing the battle sound arise.
+ */
+void Sound::playBattle()
+{
+       static const int BATTLE_LIMIT = 16;
+
+       //TODO: this is original behavior,
+       // does it make sense?
+       m_battleCount++;
+       if (m_battleCount > BATTLE_LIMIT) {
+               playSound("battle");
+               m_battleCount = 0;
+       }
+}
Index: netpanzer/src/UILib/Sound.hpp
diff -u netpanzer/src/UILib/Sound.hpp:1.3 netpanzer/src/UILib/Sound.hpp:1.4
--- netpanzer/src/UILib/Sound.hpp:1.3   Mon Sep  8 08:12:19 2003
+++ netpanzer/src/UILib/Sound.hpp       Sat Sep 13 18:38:22 2003
@@ -28,22 +28,27 @@
                _random_battle, _blow_up_tank
        };
 
+       Sound();
        virtual ~Sound()
        { }
        
-       virtual void PlayTankIdle() = 0;
-       virtual void StopTankIdle() = 0;
-       virtual void PlayMenuSound() = 0;
-       virtual void PlayAttackWarning() = 0;
-       virtual void PlayPowerUpSound() = 0;
-       virtual void PlayUnitSound(int unit_type) = 0;
-       virtual void PlayUnitVoice(int unit_type, Event event) = 0;
-       virtual void PlayAmbientSound(int unit_type, Event event, long 
distance)=0;
+       void playTankIdle();
+       void stopTankIdle();
+       void playPowerUpSound();
+       void playUnitSound(int unit_type);
+       void playBattle();
 
        virtual void playSound(const char* name) = 0;
+       virtual void playAmbientSound(const char *name, long distance)=0;
+       virtual int playSoundRepeatedly(const char* name) = 0;
+       virtual void stopChannel(int channel) = 0;
 
        virtual void playMusic(const char* directory) = 0;
        virtual void stopMusic() = 0;
+
+       private:
+       int m_tankIdleChannel;
+       int m_battleCount;
 };
 
 extern Sound* sound;




reply via email to

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