netpanzer-cvs
[Top][All Lists]
Advanced

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

[netPanzer-CVS] netpanzer/src Lib/2D/Span.cpp Lib/2D/Surface.cp...


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer/src Lib/2D/Span.cpp Lib/2D/Surface.cp...
Date: Fri, 12 Sep 2003 20:15:09 -0400

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

Modified files:
        src/Lib/2D     : Span.cpp Surface.cpp Surface.hpp 
        src/Lib/PObject/Templates: ArrayTemplate.hpp 
        src/NetPanzer/Classes/Network: NetworkState.cpp 
        src/NetPanzer/Interfaces: MouseInterface.cpp 
        src/NetPanzer/Views/MainMenu/Multi: FlagSelectionView.cpp 

Log message:
        made the flags display correctly in the menu and cleaned up a bit more 
in Surface

Patches:
Index: netpanzer/src/Lib/2D/Span.cpp
diff -u netpanzer/src/Lib/2D/Span.cpp:1.8 netpanzer/src/Lib/2D/Span.cpp:1.9
--- netpanzer/src/Lib/2D/Span.cpp:1.8   Wed Sep 10 07:26:06 2003
+++ netpanzer/src/Lib/2D/Span.cpp       Fri Sep 12 20:15:08 2003
@@ -57,7 +57,7 @@
 {
        if (!allowSpanBlitting) { return; } // Remove for release candidate.
 
-       for(size_t idx=0;idx<pixelsPerRow;idx++)
+       for(int idx=0;idx<pixelsPerRow;idx++)
                dRow[idx] = table[dRow[idx]];
 } // end bltLookupSpan
 
Index: netpanzer/src/Lib/2D/Surface.cpp
diff -u netpanzer/src/Lib/2D/Surface.cpp:1.18 
netpanzer/src/Lib/2D/Surface.cpp:1.19
--- netpanzer/src/Lib/2D/Surface.cpp:1.18       Fri Sep 12 17:37:10 2003
+++ netpanzer/src/Lib/2D/Surface.cpp    Fri Sep 12 20:15:08 2003
@@ -20,6 +20,7 @@
 #include <algorithm>
 #include "FindFirst.hpp"
 #include "Surface.hpp"
+#include "FileSystem.hpp"
 #include "UtilInterface.hpp"
 #include "cGrowList.hpp"
 #include "fXY.hpp"
@@ -87,22 +88,6 @@
    BYTE   padding[58];
  } __attribute__((packed));
 
-struct TGAHeader
-{
-       BYTE imageIDLength;
-       PIX colorMapType;
-       BYTE imageType;
-       WORD colorMapFirstIndex;
-       WORD colorMapLength;
-       PIX colorMapBitsPerEntry;
-       WORD xOrigin;
-       WORD yOrigin;
-       WORD xPix;
-       WORD yPix;
-       BYTE bitsPerPixel;
-       BYTE imageDescriptor;
-} __attribute__((packed)); // end cTGA
-
 class SurfaceHeader
 {
 public:
@@ -123,14 +108,14 @@
 } __attribute__((packed));
 
 class BitmapFileHeader
-  {
-   public:
-   WORD    bfType;
-   DWORD   bfSize;
-   WORD    bfReserved1;
-   WORD    bfReserved2;
-   DWORD   bfOffBits;
-  } __attribute__((packed));
+{
+public:
+       WORD    bfType;
+       DWORD   bfSize;
+       WORD    bfReserved1;
+       WORD    bfReserved2;
+       DWORD   bfOffBits;
+} __attribute__((packed));
 
 #define BI_RGB      0L
 #define BI_RLE8     1L
@@ -165,10 +150,8 @@
 #pragma pack()
 #endif
 
-PIX Surface::transPix = 0;
 bool Surface::screenLocked = true;
 
-
 Surface screen;
 Surface ascii8x8;
 Surface ascii5x5;
@@ -186,7 +169,6 @@
 
        totalSurfaceCount++;
        totalByteCount += sizeof(Surface);
-
 } // end Surface::Surface
 
 //---------------------------------------------------------------------------
@@ -284,7 +266,6 @@
        totalByteCount -= sizeof(Surface);
 
        assert(totalByteCount >= 0);
-
 } // end Surface::~Surface
 
 //---------------------------------------------------------------------------
@@ -324,7 +305,6 @@
        offset      = 0;
        doesExist   = 0;
        wipeCount   = 0;
-
 } // end Surface::reset
 
 // setOffsetCenter
@@ -370,8 +350,7 @@
                {
                        if (gottaHaveIt)
                        {
-                               outOfMem(requestedBytes);
-                               assert(false);
+                               throw Exception("out of memory while allocating 
surface.");
                        }
 
                        // Subtract the number of bytes for this surface.
@@ -817,7 +796,7 @@
        {
                for (int col = 0; col < pixelsPerRow; col++)
                {
-                       if (*sPtr != transPix)
+                       if (*sPtr != 0)
                                *dPtr = color;
                        sPtr++;
                        dPtr++;
@@ -1099,21 +1078,6 @@
        }
 } //end Surface::drawLine
 
-// outOfMem
-//---------------------------------------------------------------------------
-// Purpose: Displays an out of memory error.
-//---------------------------------------------------------------------------
-void Surface::outOfMem(size_t requestedBytes)
-{
-       assert(false);
-       
-       fprintf(stderr, "ERROR: Surface out of memory.");
-       //MessageBox(gapp.hwndApp, "ERROR: Surface out of memory.", "Error", 
MB_OK);
-
-       exit(1);
-
-} // end Surface::outOfMem
-
 // extractPCX
 //---------------------------------------------------------------------------
 // Purpose: Extracts PCX images from the specified PCX file.  Given the number
@@ -2260,7 +2224,7 @@
                {
                        for (int x = 0; x < pix.x; x++)
                        {
-                               if (getPixel(x, y) != transPix)
+                               if (getPixel(x, y) != 0)
                                {
                                        if (x < bounds.min.x)
                                        {
@@ -2279,7 +2243,7 @@
                {
                        for (int y = 0; y < pix.y; y++)
                        {
-                               if (getPixel(x, y) != transPix)
+                               if (getPixel(x, y) != 0)
                                {
                                        if (y < bounds.min.y)
                                        {
@@ -2333,263 +2297,6 @@
        return average+getRand(-ruggedness, ruggedness)*float(distance);
 }
 
-// frac
-//---------------------------------------------------------------------------
-// Purpose: Recursively creates a random fractal image.
-//---------------------------------------------------------------------------
-void frac(int *matrix, int stride, int x1, int y1, int x2, int y2, float 
ruggedness)
-{
-       assert(matrix != 0);
-
-       int xm, zm;
-
-       assert(x1 <= x2);
-       assert(y1 <= y2);
-       assert(x1 >= 0);
-       assert(y1 >= 0);
-
-       xm = (x1+x2+1)/2;
-       zm = (y1+y2+1)/2;
-
-       float tl = matrix[y1 * stride + x1];
-       float bl = matrix[y2 * stride + x1];
-       float tr = matrix[y1 * stride + x2];
-       float br = matrix[y2 * stride + x2];
-
-       // If the rectangle is at least 3 cells tall, check
-       // if the middle left cell has been filled in, and if
-       // not, then stick in a value
-       if (zm < y2)
-       {
-
-               // See if the middle left cell has been set
-               if (matrix[zm * stride + x1] == -10000)
-               {
-                       // Not filled in - generate a random cell value
-                       matrix[zm * stride + x1] = (int) (calcY((tl+bl)/2.0, 
ruggedness,
-                                               y2-y1));
-               }
-
-               // Fill in the middle right cell.  We know it hasn't
-               // been set because of the order in which we fill in
-               // the smaller squares
-               if (matrix[zm * stride + x2] != -10000.0) {
-                       throw Exception("1. matrix[%u, %u] != -10000 - value: 
%d",
-                                                       zm, x2, matrix[zm * 
stride + x2]);
-               }
-               if (x1 < x2)
-                       matrix[zm * stride + x2] = (int) (calcY((tr+br)/2.0, 
ruggedness,
-                                               y2-y1));
-       }
-
-       // Do the same for the top-middle and bottom-middle cells
-       if (xm < x2)
-       {
-               if (matrix[y1 * stride + xm] == -10000.0)
-                       matrix[y1 * stride + xm] = (int) (calcY((tl+tr)/2.0, 
ruggedness,
-                                               x2-x1));
-               if (matrix[y2 * stride + xm] != -10000.0) 
-                       throw Exception("2. matrix[%u, %u] != -10000 - value: 
%d",
-                                                       y2, xm, matrix[y2 * 
stride + xm]);
-               if (y1 < y2)
-                       matrix[y2 * stride + xm] = (int) (calcY((bl+tr)/2.0, 
ruggedness,
-                                               x2-x1));
-       }
-
-       // Fill in the middle cell value.  If our square is at
-       // least 3x3, then this cell should have not yet been set
-       if (xm < x2 && zm < y2)
-       {
-               if (matrix[zm * stride + xm] != -10000.0) {
-                       throw Exception("3. matrix[%u, %u] != -10000 - value: 
%d", zm, xm, matrix[zm * stride + xm]);
-               }
-               matrix[zm * stride + xm] = (int) (calcY((tl+tr+bl+br)/4.0, 
ruggedness,
-                                       (x2-x1)+(y2-y1)));
-       }
-
-       // Now recursivly do the smaller squares
-       if (xm < x2 || zm < y2)
-       {
-               frac(matrix, stride, x1, y1, xm, zm, ruggedness);
-               frac(matrix, stride, x1, zm, xm, y2, ruggedness);
-               frac(matrix, stride, xm, y1, x2, zm, ruggedness);
-               frac(matrix, stride, xm, zm, x2, y2, ruggedness);
-       }
-
-       // Since we've finished this square, every cell in the square
-       // should have been filled in.
-       for (int x = x1; x < x2 ; ++x) {
-               for (int z = y1; z < y2 ; ++z) {
-                       if (matrix[z * stride + x] == -10000.0) {
-                               if (matrix[z * stride + x] != -10000.0) {
-                                       throw Exception("4. matrix[%u, %u] != 
-10000 - value: %d", z, x, matrix[z * stride + x]);
-                               }
-                       }
-               }
-       }
-} // end Surface::frac
-
-// createFractal
-//---------------------------------------------------------------------------
-// Purpose: Create a fractal image onto the Surface.
-//---------------------------------------------------------------------------
-void Surface::createFractal(const float &minY, const float &maxY, const float 
&ruggedness)
-{
-       assert(getDoesExist());
-       assert(this != 0);
-
-       // Create some temp buffer to generate the values in.
-       int *tempBuf = (int *) malloc(stride * pix.y * sizeof(int));
-       if (tempBuf == 0) { throw Exception("ERROR: Unable to allocate temp 
fractal surface.");
-       }
-
-       // Initialize everything to some bogus value.
-       for (int x = 0; x < stride; x++)
-               for (int y = 0; y < pix.y; y++)
-                       tempBuf[y * stride + x] = -10000;
-
-       //for (int num = 0; num < stride*pix.y; num++)
-       //      LOG(("%d tempBuf: %d", num, tempBuf[num]));
-       //throw Exception("!EXIT!");;
-
-       // Initialize the corners to some value.
-       tempBuf[0]                           = (int) getRand(minY, maxY);
-       tempBuf[stride-1]                    = (int) getRand(minY, maxY);
-       tempBuf[pix.y-1 * stride-1]          = (int) getRand(minY, maxY);
-       tempBuf[pix.y-1 * stride + stride-1] = (int) getRand(minY, maxY);
-
-       // Recursively generate the fractal surface
-       frac(tempBuf, stride, 0, 0, stride-1, pix.y-1, ruggedness);
-
-       int yMin = tempBuf[0];
-       int yMax = tempBuf[0];
-
-       for (int x = 0; x < stride; x++)
-       {
-               for (int y = 0; y < pix.y; y++)
-               {
-                       //if (tempBuf[y * stride + x] < 0)   tempBuf[y * stride 
+ x] = 0;//throw Exception("tempBuf[y * stride + x] < 0,   value: %d", 
tempBuf[y * stride + x]);
-                       //if (tempBuf[y * stride + x] > 255) tempBuf[y * stride 
+ x] = 255;//throw Exception("tempBuf[y * stride + x] > 255, value: %d", 
tempBuf[y * stride + x]);
-                       //LOG(("tempBuf[y * stride + x]: %d", tempBuf[y * 
stride + x]));
-                       if (tempBuf[y * stride + x] < yMin) yMin = tempBuf[y * 
stride + x];
-                       if (tempBuf[y * stride + x] > yMax) yMax = tempBuf[y * 
stride + x];
-               }
-       }
-
-       int   difference = yMax - yMin;
-       float ratio      = 255.0/float(difference);
-
-       for (int x = 0; x < stride; x++)
-       {
-               for (int y = 0; y < pix.y; y++)
-               {
-                       // Push all the min values to sea level (0) if the min 
is less than 0.
-                       if (yMin < 0)
-                       {
-                               tempBuf[y * stride + x] -= yMin;
-                       }
-                       // Move the land to be within the range [0, 255].
-                       int value = (int) (tempBuf[y * stride + x]*ratio);
-                       assert(value < 256);
-                       tempBuf[y * stride + x] = value;
-                       //LOG(("tempBuf[y * stride + x], value: %d", tempBuf[y 
* stride + x]));
-               }
-       }
-
-       fill(Color::black);
-       //for (int y = 0; y < pix.y; y++)
-       //{
-               memcpy(frame0, tempBuf, stride*pix.y);
-       //}
-
-       smooth();
-       smooth();
-       smooth();
-
-} // end Surface::createFractal
-
-#if _MSC_VER > 1000
- #pragma optimize( "", off )
-#endif
-void Surface::fire(int *dest, int xSize, int ySize)
-{
-       printf ("Fire not implemented in gcc yet!\n");
-       // XXX no msvc assembler
-#ifdef MSVC
-       _asm {
-
-               mov edi, [dest]
-               mov ecx, [xSize]
-               mov ebx, [ySize]
-
-               add  edi,4
-               lea  esi,[ecx*4]
-               imul ecx,ebx
-               sub  ecx,ebx
-               sub  ecx,ebx
-               sub  ecx,2
-       fl1:
-               mov  ebx,[edi]
-               mov  edx,[edi+esi-4]
-               lea  eax,[ebx + edx]
-               mov  ebx,[edi+esi+4]
-               mov  edx,[edi+esi*2]
-               add  eax,ebx
-               add  eax,edx
-               add  edi,4
-               shr  eax,2
-               jz   fl2
-               dec  eax
-       fl2:
-               dec  ecx
-               mov  [edi+esi-4], eax
-               jnz  fl1
-       }
-#endif
-       
-}
-
-// smooth
-//---------------------------------------------------------------------------
-// Purpose: Makes every pixel the average of its four neighbors oolor.
-//          This is NOT complete, needs to be finished.
-//---------------------------------------------------------------------------
-void Surface::smooth()
-{
-       assert(getDoesExist());
-       assert(this != 0);
-
-       const int XP = pix.x;
-       const int ZP = pix.y;
-
-       // First erode the edges
-       putPixel( 0,  0, (getPixel(   0,    1)+getPixel(   1,    1)+getPixel( 
1,    0))/3); // NW
-       putPixel( 0, ZP, (getPixel(   0, ZP-1)+getPixel(   1, ZP-1)+getPixel( 
1,   ZP))/3); // SW
-       putPixel(XP,  0, (getPixel(XP-1,    0)+getPixel(XP-1,    
1)+getPixel(XP,    0))/3); // NE
-       putPixel(XP, ZP, (getPixel(XP-1, ZP-1)+getPixel(XP-1,   
ZP)+getPixel(XP, ZP-1))/3); // SE
-
-       // NORTH EDGE
-       for (int x = 1; x < pix.x; x++)
-               putPixel(x, 0, (getPixel(x-1, 1)+getPixel(x, 1)+getPixel(x+1, 
1))/3);
-
-       // SOUTH EDGE
-       for (int x = 1; x < pix.x; x++)
-               putPixel(x, ZP, (getPixel(x-1, ZP-1)+getPixel(x, 
ZP-1)+getPixel(x+1, ZP-1))/3);
-
-       // WEST EDGE
-       for (int y = 1; y < pix.y; y++)
-               putPixel(0, y, (getPixel(1, y-1)+getPixel(1, y)+getPixel(1, 
y+1))/3);
-
-       // EAST EDGE
-       for (int y = 1; y < pix.y; y++)
-               putPixel(XP, y, (getPixel(XP, y-1)+getPixel(XP, y)+getPixel(XP, 
y+1))/3);
-
-       // Then erode the inner area
-       for (int x = 1; x < pix.x; x++)
-               for (int y = 1; y < pix.y; y++)
-                       putPixel(x, y, (getPixel(x-1, y)+getPixel(x+1, 
y)+getPixel(x, y-1)+getPixel(x, y+1))/4);
-} // end smooth
-
 // getAverageColor
 //---------------------------------------------------------------------------
 // Purpose: Recalculates the best single color to represent this Surface.
@@ -2621,42 +2328,6 @@
        return Palette::findNearestColor(RGBColor(avgR, avgG, avgB));
 } // end Surface::getAverageColor
 
-// saveRAW
-//---------------------------------------------------------------------------
-// Purpose: Save a RAW file of the first frame of the Surface into the 
-//          specified file handle.
-//---------------------------------------------------------------------------
-void Surface::saveRAW(FILE *fp) const
-{
-       if (fp == 0) return;
-
-       int numBytes = pix.x * pix.y * sizeof(PIX);
-       
-       if (numBytes <= 0) return;
-       if (frame0 == 0) return;
-
-       fwrite(frame0, numBytes, 1, fp);
-
-} // end Surface::saveRAW
-
-// saveRAW
-//---------------------------------------------------------------------------
-// Purpose: Save a RAW file of the first frame of the Surface into the
-//          specified filename.  Returns 0 on error, 1 on success.
-//---------------------------------------------------------------------------
-int Surface::saveRAW(const char *filename) const
-{
-       FILE *fp = fopen(filename, "wb");
-       if (fp == 0) return 0;
-
-       saveRAW(fp);
-
-       fclose(fp);
-       
-       return 1;
-
-} // end Surface::saveRAW
-
 // loadTIL
 //---------------------------------------------------------------------------
 int Surface::loadTIL(const char* filename)
@@ -3577,352 +3248,6 @@
        return 1;
 } // end loadAllRAWInDirectory
 
-// explode
-void Surface::explode(const double &time)
-{
-    //Duplicate image
-    //int[] sourcePixels=pixels;
-    //pixels = new int[width * height];
-       Surface tempSurface;
-       tempSurface.create(pix, pix.x, 1);
-       this->blt(tempSurface);
-       this->fill(Color::black);
-
-    //int[] zBuffer = new int[width * height];
-       int *zBuffer = new int[getArea()];
-       if (zBuffer == 0)
-       {
-               throw Exception("Unable to allocate zBuffer.");
-       }
-    
-       //Random rnd=new Random();
-    //Make sure the same sequence of random numbers are returned for each call 
to explode
-    //rnd.setSeed(0);
-       srand(0);
-
-    int index = 0;
-    
-       //This is the y value added because of gravity
-    double yOffset = ((time + 1.0f) * (time * 1.0f)) / 60.0f;
-
-    for (int y = -center.y; y < center.y; y++)
-       {
-       for (int x = -center.x; x < center.x; x++)
-       {
-               //int c = sourcePixels[index];
-                       int c = tempSurface.getPixel(x, y);
-               
-                       //if ((c&0xff000000) != 0)
-                       if (c != 0)
-               {
-                       //Calculate distance from center, or the ‘bomb’
-                       //double d = Math.sqrt(x*x+y*y);
-                       double d = sqrt(x * x + y * y);
-
-                       //Pixel's z, or depth, value
-                       //double z=(rnd.nextDouble()+1)*time/d;
-                       double z = (float(rand() % RAND_MAX) / float(rand() % 
RAND_MAX) + 1) * time / d;
-
-                       //Calculate x and y destination, add perspective
-                       int xd = (int)(x * z + x) + center.x;
-                       int yd = (int)((y + yOffset) * z + y) + center.y;
-
-                //Calculate the pixels offset in the pixels array
-                       int offset = xd + yd * pix.x;
-                       
-                               if (xd >= 0 && xd < pix.x && yd >= 0 && yd < 
pix.y)
-                               {
-                    
-                                       //Check to see if another pixel blocks 
this
-                               if (zBuffer[offset] <= z)
-                               {
-                                       //The pixel is unblocked, plot and 
update z, or depth, value
-                                       //pixels[offset]  = c;
-                                               this->putPixel(xd, yd, c);
-
-                                       //zBuffer[offset] = (int)z;
-                                               zBuffer[offset] = (int)z;
-                               }
-                               }
-               }
-                       index++;
-          }
-       }
-       delete [] zBuffer;
-} // end explode
-
-/*
-//---------------------------------------------------------------------------
-int Surface::loadTGA(const char *filename)
-{
-       FILE *fp = fopen(filename, "rb");
-       if (fp == 0) return 0;
-
-       loadTGA(fp);
-
-       fclose(fp);
-       
-       return 1;
-} // end loadTGA
-
-class cPixel24Bit
-{
-       BYTE r;
-       BYTE g
-       BYTE b;
-       BYTE v;
-}; // end cPixel24Bit
-
-class Surface24Bit
-{
-       loadTGA();
-};
-
-//---------------------------------------------------------------------------
-int loadTGA(FILE *file, cPixel24Bit *dest)
-{
-
-       assert(&this != 0);
-
-       // Read in the TGA header.
-       cTGAHeader TGAheader;
-       fread(&TGAheader, sizeof(TGAheader), 1, fp);
-
-       BYTE        *buffer;
-
-       // Read in the header
-       fread(&TGAheader, sizeof(TGAheader), 1, fp);
-
-       // Check for uncompressed/true-color.
-       if (TGAheader.imageType != UNCOMPRESSEDtrueCOLOR) 
-       {
-               throw Exception("ERROR: TGAheader.imageType != 
UNCOMPRESSEDtrueCOLOR");
-       }
-
-       // Check for 24-bits per pixel.
-       if (TGAheader.bitsPerPixel != 24) 
-       {
-               throw Exception("ERROR: TGAheader.bitsPerPixel != 24");
-       }
-
-       // Mark the starting point of the image data
-       long dataStartPos = ftell(f);
-
-       // Set the size
-       iXY size(TGAheader.width, TGAheader.height);
-
-       int xGoofy, yGoofy;
-
-       switch (header.imageDescriptor) 
-       {
-               case ORIGIN_BOTTOMLEFT:  xGoofy = 0; yGoofy = 1; break;
-               case ORIGIN_BOTTOMRIGHT: xGoofy = 1; yGoofy = 1; break;
-               case ORIGIN_TOPLEFT:     xGoofy = 0; yGoofy = 0; break;
-               case ORIGIN_TOPRIGHT:    xGoofy = 1; yGoofy = 0; break;
-               default: return 0;
-       }
-
-       if (dest != 0)
-       {
-               delete [] dest;
-       }
-
-       dest  = new SPixel [size.x * size.y * sizeof(cPixel24Bit)];
-
-       // Read in image
-       buffer = (BYTE *) malloc(size.x * 3);
-
-       // Top-down or bottom-up?
-       int yStart, yEnd, yStep;
-
-       if (yGoofy) 
-       { 
-               yStart = ys-1; 
-               yEnd = -1; 
-               yStep = -1; 
-       } else
-       {
-               yStart = 0; 
-               yEnd = ys; 
-               yStep = +1; 
-       }
-
-       // Left->Right or Right->Left?
-       int xStart, xEnd, xStep;
-
-       if (xGoofy)
-       { 
-               xStart = xs-1; 
-               xEnd = -1; 
-               xStep = -1; 
-       } else 
-       { 
-               xStart = 0; 
-               xEnd = xs; 
-               xStep = +1; 
-       }
-
-       for (int y = yStart; y != yEnd; y += yStep)
-       {
-               dest = bitmap + (y * xs);
-
-               fread(buffer, xs * 3, 1, f);
-
-               for (int x = xStart; x != xEnd; x += xStep)
-               {
-                       dest->r = buffer[(x * 3) + 2];
-                       dest->g = buffer[(x * 3) + 1];
-                       dest->b = buffer[(x * 3) + 0];
-                       dest->v = 0;
-
-                       ++dest;
-               }
-       }
-
-       free(buffer);
-
-       cornerX1 = 0;
-       cornerY1 = 0;
-       cornerX2 = xs - 1;
-       cornerY2 = ys - 1;
-
-       // Return success!
-       return(1);
-} // loadTGA
-*/
-
-// Surface::saveRAW
-//---------------------------------------------------------------------------
-// Purpose: Dumps an incrementally numbered RAW file of the Surface.
-//---------------------------------------------------------------------------
-bool Surface::saveRAW()
-{
-       char strBuf[256];
-       int  num = 0;
-
-       // Incrementally create screen shots.
-       for(;;)
-       {
-               sprintf(strBuf, "shot%04d.raw", num);
-
-               if (UtilInterface::getFileSize(strBuf) <= 0)
-               {
-                       if (!saveRAW(strBuf))
-                       {
-                               return false;
-                               //sprintf(progressBuf, "Error saving screen 
shot: %d.raw", num);
-                               //progressView->scrollAndUpdate(progressBuf);
-                               //break;
-                       }
-
-                       //sprintf(progressBuf, "Screen shot saved(%d, %d): 
%d.raw", pix.x, pix.y, num);
-                       //progressView->scrollAndUpdate(progressBuf);
-                       //break;
-                       return true;
-               } else num++;
-       }
-       return true;
-} // end Surface::saveRAW
-
-// convertBW
-//--------------------------------------------------------------------------
-// Purpose: Converts the image to the best black and white representation it 
-//          can.
-//--------------------------------------------------------------------------
-void Surface::convertBW()
-{
-       assert(Palette::gray256.getColorCount() == 256);
-
-       for (int x = 0; x < pix.x; x++)
-       {
-               for (int y = 0; y < pix.y; y++)
-               {
-                       putPixel(x, y, Palette::gray256[getPixel(x, y)]);
-               }
-       }
-} // end Surface::convertBW
-
-//--------------------------------------------------------------------------
-void Surface::drawPalette()
-{
-       iXY  pos;
-       BYTE color = 0;
-
-       iXY dimension(SCREEN_XPIX / 16, SCREEN_YPIX / 16);
-
-       for (int y = 0; y < SCREEN_YPIX; y += dimension.y)
-       {
-               for (int x = 0; x < SCREEN_XPIX; x += dimension.x)
-               {
-                       fillRect(x, y, x + dimension.x, y + dimension.y, color);
-                       color++;
-               }
-       }
-}
-
-//--------------------------------------------------------------------------
-void fireByte(BYTE *dest, int xSize, int ySize)
-{
-       printf("no gcc version of fireByte yet.\n");
-
-       // XXX no msvc assembler
-#ifdef MSVC    
-       _asm {
-
-               mov edi, [dest]
-               mov ecx, [xSize]
-               mov ebx, [ySize]
-
-               inc  edi
-               mov  esi,ecx
-               imul ecx,ebx
-               sub  ecx,ebx
-               sub  ecx,ebx
-               sub  ecx,2
-               xor  ebx,ebx
-               xor  edx,edx
-       fl1:
-               mov  bl,[edi]
-               mov  dl,[edi+esi-1]
-               lea  eax, [ebx + edx]
-               mov  bl,[edi+esi+1]
-               mov  dl,[edi+esi*2]
-               add  eax,ebx
-               add  eax,edx
-               inc  edi
-               shr  eax,2
-               jz   fl2
-               dec  al
-       fl2:
-               dec  ecx
-               mov  [edi+esi-1], al
-               jnz  fl1
-       }
-#endif
-
-}
-
-//--------------------------------------------------------------------------
-void Surface::erode()
-{
-       fireByte(frame0, pix.x, pix.y);
-}
-
-//--------------------------------------------------------------------------
-void Surface::setToColorTable(const ColorTable &source)
-{
-       //assert(source.getColorCount() == 256);
-
-       for (int x = 0; x < pix.x; x++)
-       {
-               for (int y = 0; y < pix.y; y++)
-               {
-                       putPixel(x, y, source[getPixel(x, y)]);
-               }
-       }
-}
-
-
 // initFont
 //---------------------------------------------------------------------------
 // Purpose: Load all the characters into a surface of 128 frames.  Then the
@@ -4273,7 +3598,8 @@
 
                for (int col = 0; col < pixelsPerRow; col++)
                {
-                       if (*sPtr != transPix) *dPtr = color;
+                       if (*sPtr != 0)
+                               *dPtr = color;
                        sPtr++;
                        dPtr++;
                }
@@ -4283,27 +3609,6 @@
        }
 }
 
-// convertTransColor
-//---------------------------------------------------------------------------
-void Surface::convertTransColor(const PIX &color)
-{
-       for (int i = 0; i < frameCount; i++)
-       {
-               setFrame(i);
-               
-               for (int x = 0; x < pix.x; x++)
-               {
-                       for (int y = 0; y < pix.y; y++)
-                       {
-                               if (getPixel(x, y) != 0)
-                               {
-                                       putPixel(x, y, color);
-                               }
-                       }
-               }
-       }
-} // end Surface::convertTransColor
-
 // lock
 //---------------------------------------------------------------------------
 void Surface::lock(PIX *memBuf)
@@ -4328,7 +3633,6 @@
 {
        reset();
        alloc(nPix, true, nStride, nFrameCount);
-
 } // end Surface::create
 
 // nextFrame
@@ -4350,24 +3654,6 @@
        return 1;
 }
 
-// drawStatic
-//---------------------------------------------------------------------------
-// Purpose: Draws static (like a t.v. station at 3AM) on the surface.
-//---------------------------------------------------------------------------
-void Surface::drawStatic()
-{
-       for (int x = 0; x < pix.x; x++)
-       {
-               for (int y = 0; y < pix.y; y++)
-               {
-                       putPixel(x, y, rand() % 256);
-               }
-       }
-
-       convertBW();
-
-} // end Surface::drawStatic
-
 void Surface::loadBMP(const char *fileName, bool needAlloc /* = true */,
                          void *returnPalette /* = 0 */)
  {
@@ -4480,23 +3766,6 @@
        drawLine(rect.min.x + 0, rect.max.y - 1, rect.max.x,     rect.max.y - 
1, dark); //S
        drawLine(rect.max.x - 1, rect.max.y,     rect.max.x - 1, rect.min.y + 
0, dark); //E
        drawLine(rect.min.x + 2, rect.max.y - 3, rect.min.x + 2, rect.min.y + 
2, dark); //W
-
-       // Draw the border of the window
-       //drawLine(0,         0,         pix.x,   0,         light); //N
-       //drawLine(2,         pix.y - 3, pix.x-2, pix.y - 3, light); //S
-       //drawLine(pix.x - 3, pix.y - 2, pix.x-3, 2,         light); //E
-       //drawLine(0,         pix.y,     0,       0,         light); //W
-       //
-       //drawLine(1,         1,         pix.x - 1, 1,         medium); //N
-       //drawLine(1,         pix.y - 2, pix.x - 2, pix.y - 2, medium); //S
-       //drawLine(pix.x - 2, pix.y - 1, pix.x - 2, 1,         medium); //E
-       //drawLine(1,         pix.y,     1,         1,         medium); //W
-       //
-       //drawLine(2,         2,         pix.x - 4, 2,         dark); //N
-       //drawLine(0,         pix.y - 1, pix.x,     pix.y - 1, dark); //S
-       //drawLine(pix.x - 1, pix.y,     pix.x - 1, 0,         dark); //E
-       //drawLine(2,         pix.y - 3, 2,         2,         dark); //W
-
 } // end Surface::drawWindowsBorder
 
 // bltStringInBox
@@ -4579,31 +3848,26 @@
        BYTE     bestFitArray[256];
        RGBColor sourceColor[256];
 
-       FILE *fp;
+       ReadFile* file = FileSystem::openRead(oldPalette);
 
-       if ((fp = fopen(oldPalette, "rb")) == 0)
+       for (int i = 0; i < 256; i++)
        {
-               throw Exception("Unable to open palette file: %s", (const char 
*) oldPalette);
+               if(file->read(&sourceColor[i], 3, 1) != 1) {
+                       delete file;
+                       throw Exception("Error while loading palette '%s'.", 
oldPalette);
+               }
        }
+       delete file;
 
-       {for (int i = 0; i < 256; i++)
-       {
-           fread(&sourceColor[i], 3, 1, fp);
-       }}
-
-       {for (int i = 0; i < 256; i++)
+       for (int i = 0; i < 256; i++)
        {
                bestFitArray[i] = Palette::findNearestColor(sourceColor[i]);
-       }}
+       }
 
-       for (int x = 0; x < pix.x; x++)
+       for (size_t x = 0; x < pix.x * pix.y * frameCount; x++)
        {
-               for (int y = 0; y < pix.y; y++)
-               {
-                       putPixel(x, y, bestFitArray[getPixel(x, y)]);
-               }
+               frame0[x] = bestFitArray[frame0[x]];
        }
-
 } // end Surface::mapFromPalette
 
 // drawBoxCorners
Index: netpanzer/src/Lib/2D/Surface.hpp
diff -u netpanzer/src/Lib/2D/Surface.hpp:1.7 
netpanzer/src/Lib/2D/Surface.hpp:1.8
--- netpanzer/src/Lib/2D/Surface.hpp:1.7        Fri Sep 12 17:37:10 2003
+++ netpanzer/src/Lib/2D/Surface.hpp    Fri Sep 12 20:15:08 2003
@@ -70,13 +70,6 @@
        uint8_t    avgIndex;  // Closest palette entry to the average color
 } __attribute__((packed)); // end FletchTileHeader
 
-//struct PIC_HEAD
-//{
-//     uint32_t xPix;         // Horizontal pixel count.
-//     uint32_t yPix;         // Vertical pixel count.
-//     uint32_t frameCount;    // Number of frames.
-//} __attribute__((packed));
-
 #ifdef MSVC
 #pragma pack ()
 #endif
@@ -89,14 +82,6 @@
 class Surface
 {
 public:
-// XXX this function seems pointless and does a noop
-#if 0
-       void setTransPix()
-       {
-               assert(transPix >= 0);
-               Surface::transPix = transPix;
-       }
-#endif
        void setOffset(const iXY &offset) { Surface::offset = offset; }
        void setOffsetX(int offset) { Surface::offset.x = offset; }
        void setOffsetY(int offset) { Surface::offset.y = offset; }
@@ -160,14 +145,9 @@
        static int    getTotalByteCount() { return totalByteCount; }
 
 protected:
-       static PIX transPix;
-
-       // This is called when we run out of memory.
-       void static outOfMem(size_t bytesRequested);
        void        reset();
 
 public:
-
        Surface();
        Surface(bool nMyMem);
        Surface(const iXY &nPix, int nStride, int nFrameCount);
@@ -335,8 +315,6 @@
        void flipVertical();
        void rotate(int angle);
        void copy(Surface &dest);
-       void createFractal(const float &minY, const float &maxY, const float 
&ruggedness);
-       void smooth();
        void setBrightness(int percent);
        int nextFrame();
 
@@ -385,9 +363,7 @@
        void loadPCX(const char *filename, bool needAlloc = true, void 
*returnPalette = 0);
        void extractPCX(const char *filename, int nCols, int gapSpace);
        void loadRAW(const char *fileName, bool needAlloc = true);
-       int  saveRAW(const char *filename) const;
-       void saveRAW(FILE *fp) const;
-       bool saveRAW();
+       
        virtual int  loadTIL(const char* filename);
        virtual void loadTIL(FILE *fp);
        int  saveTIL(const char *filename);
@@ -406,7 +382,7 @@
        {
                blendRect(iRect(0, 0, pix.x - 1, pix.y - 1), colorTable);
        }
-       //void bltBrightness(const Surface &dest, const iXY pos, ColorTable 
&colorTable);
+       
        void bltBrightness(const Surface &dest, const iXY &pos, const float 
&percent);
        void bltLightDark(const Surface &source, const Surface &lightTable) 
const;
        void setToBrightnessIndexes128();
@@ -415,16 +391,7 @@
        int  loadAllPCXInDirectory(const char *path);
        int  loadAllBMPInDirectory(const char *path);
        int  loadAllRAWInDirectory(const char *path, const iXY &pix);
-       void fire(int *dest, int xSize, int ySize);
-       void explode(const double &time);
 
-       void convertBW();
-       void erode();
-       void drawStatic();
-       void setToColorTable(const ColorTable &source);
-       void drawPalette();
-       void convertTransColor(const PIX &color);
-       
        // Blit a single character of text.
        void bltChar8x8(const iXY &pos, const char &character, const PIX 
&color) const;
        inline void bltChar8x8(int x, int y, const char &character, const PIX 
&color) const
Index: netpanzer/src/Lib/PObject/Templates/ArrayTemplate.hpp
diff -u netpanzer/src/Lib/PObject/Templates/ArrayTemplate.hpp:1.4 
netpanzer/src/Lib/PObject/Templates/ArrayTemplate.hpp:1.5
--- netpanzer/src/Lib/PObject/Templates/ArrayTemplate.hpp:1.4   Wed Sep 10 
08:03:17 2003
+++ netpanzer/src/Lib/PObject/Templates/ArrayTemplate.hpp       Fri Sep 12 
20:15:08 2003
@@ -19,6 +19,7 @@
 #define _ARRAYTEMPLATE_HPP
 
 #include <assert.h>
+#include <string.h>
 #include <stdlib.h>
 
 template< class TYPE >
Index: netpanzer/src/NetPanzer/Classes/Network/NetworkState.cpp
diff -u netpanzer/src/NetPanzer/Classes/Network/NetworkState.cpp:1.3 
netpanzer/src/NetPanzer/Classes/Network/NetworkState.cpp:1.4
--- netpanzer/src/NetPanzer/Classes/Network/NetworkState.cpp:1.3        Fri Sep 
 5 22:01:18 2003
+++ netpanzer/src/NetPanzer/Classes/Network/NetworkState.cpp    Fri Sep 12 
20:15:08 2003
@@ -16,6 +16,7 @@
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 #include <config.h>
+
 #include <stdio.h>
 #include "NetworkState.hpp"
 
@@ -127,46 +128,6 @@
  }
 
 
-void NetworkState::logNetworkStats( void )
- {
-  FILE *fp;
-
-  fp = fopen( "NetworkStats.log", "at" );
-
-  fprintf(fp, "Packets\n" );
-       
-       
-  fprintf(fp, "Sent %d, %.4f 1/s, %.4f Avg\n",NetworkState::packets_sent,
-                                                  
NetworkState::packets_sent_per_sec,
-                                                  ((float) 
NetworkState::packets_sent) / ((float) NetworkState::packets_sent_time) );
-
- 
-  fprintf(fp, "Recv %d, %.4f 1/s, %.4f Avg\n",NetworkState::packets_received,
-                                                  
NetworkState::packets_received_per_sec,
-                                                  ((float) 
NetworkState::packets_received) / ((float) NetworkState::packets_received_time) 
);
-       
-  fprintf(fp, "Bytes\n" );
-       
-
-       
-  fprintf(fp, "Sent %d, %.4f 1/s, %.4f Avg\n",NetworkState::bytes_sent,
-                                                  
NetworkState::bytes_sent_per_sec,
-                                                  ((float) 
NetworkState::bytes_sent) / ((float) NetworkState::packets_sent_time) );
-
-  
-  fprintf(fp, "Recv %d, %.4f 1/s, %.4f Avg\n",NetworkState::bytes_received,
-                                                  
NetworkState::bytes_received_per_sec,
-                                                  ((float) 
NetworkState::bytes_received) / ((float) NetworkState::packets_received_time) );
-
-  fprintf(fp, "Opcodes\n" );
-
-  fprintf(fp, "Sent : %d, %.4f 1/s\n ", NetworkState::opcodes_sent,
-                                          NetworkState::opcodes_sent_per_sec );
-
-  fprintf(fp, "Recv : %d, %.4f 1/s\n", NetworkState::opcodes_received,
-                                           
NetworkState::opcodes_received_per_sec );
-  
-  fprintf(fp, 
"-------------------------------------------------------------\n" );
-
-  fclose( fp );
- }
+void NetworkState::logNetworkStats()
+{
+}
Index: netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp:1.8 
netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp:1.9
--- netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp:1.8   Thu Sep 11 
13:35:47 2003
+++ netpanzer/src/NetPanzer/Interfaces/MouseInterface.cpp       Fri Sep 12 
20:15:08 2003
@@ -24,11 +24,8 @@
 
 #include "cMouse.hpp"
 
-#ifndef _MAP_EDITOR_BUILD
-// ** NOTE: TEMPORARY UNIT MOUSE STANDARDIZED
 #include "Gdatstct.hpp"
 sprite_dbase CURSOR_DBASE;
-#endif // ** _MAP_EDITOR_BUILD
 
 unsigned char MouseInterface::cursor_x_size;
 unsigned char MouseInterface::cursor_y_size;
@@ -67,10 +64,7 @@
 {
        event_queue.initialize( 20 );
        mouse_cursor.setOffsetCenter();
-#ifndef _MAP_EDITOR_BUILD
-       // ** NOTE: TEMPORARY
-       CURSOR_DBASE.load_dbase( "./gdbase/cursor.dbs" );
-#endif // ** _MAP_EDITOR_BUILD
+       CURSOR_DBASE.load_dbase( "gdbase/cursor.dbs" );
 }
     
 bool MouseInterface::buttonHeld(unsigned char mask)
@@ -268,7 +262,6 @@
 
 void MouseInterface::setCursor(CursorType type)
 {
-  #ifndef _MAP_EDITOR_BUILD
        switch(type)
        {
     case defaultcursor:
@@ -355,7 +348,6 @@
     break;
 
    } // ** switch 
-  #endif // ** _MAP_EDITOR_BUILD
 }
     
 void MouseInterface::updateCursor()
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.9 
netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.10
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp:1.9      
Fri Sep 12 10:12:45 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/FlagSelectionView.cpp  Fri Sep 
12 20:15:08 2003
@@ -68,6 +68,7 @@
        if (playerFlag.loadAllBMPInDirectory("pics/flags/") <= 0)
                throw Exception("Couldn't find flags for menu in '%s'.",
                                "pics/flags/");
+       playerFlag.mapFromPalette("wads/netp.act");
 
        iXY flagStartOffset(BORDER_SPACE, BORDER_SPACE * 2 + 
playerFlag.getPixY());
 




reply via email to

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