netpanzer-cvs
[Top][All Lists]
Advanced

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

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


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer/src Makefile configure Lib/FileSystem...
Date: Fri, 19 Sep 2003 11:22:31 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/09/19 11:22:30

Modified files:
        src            : Makefile configure 
        src/Lib        : FileSystem.hpp 
        src/Lib/2D     : Surface.cpp Surface.hpp 
        src/Lib/Interfaces: UtilInterface.cpp UtilInterface.hpp 
        src/Lib/optionmm: command_line.hpp 

Log message:
        more fixes to make the thing compiling in win32 again

Patches:
Index: netpanzer/src/Lib/2D/Surface.cpp
diff -u netpanzer/src/Lib/2D/Surface.cpp:1.23 
netpanzer/src/Lib/2D/Surface.cpp:1.24
--- netpanzer/src/Lib/2D/Surface.cpp:1.23       Tue Sep 16 16:16:09 2003
+++ netpanzer/src/Lib/2D/Surface.cpp    Fri Sep 19 11:22:30 2003
@@ -17,6 +17,8 @@
 */
 #include <config.h>
 
+#include <vector>
+#include <string>
 #include <algorithm>
 #include "FindFirst.hpp"
 #include "Log.hpp"
@@ -2835,38 +2837,19 @@
 //---------------------------------------------------------------------------
 int Surface::loadAllTILInDirectory(const char *path)
 {
-    char strBuf[256];
-    char pathWild[256];
-
-    sprintf(pathWild, "%s*.til", path);
-
-    int imageCount = UtilInterface::getNumFilesInDirectory(pathWild);
-    if (imageCount <= 0) {
-        return 0;
-    }
-
-    struct _finddata_t myFile;
-    int* hFile;
-
-    _findfirst(pathWild, &myFile);
-
-    // Find the dimensions of the first file.
+    char** list = FileSystem::enumerateFiles(path);
+    
+    std::vector<std::string> filenames;
     Surface tempSurface;
-
-    cGrowList <Filename> filenames;
-    filenames.setNum(imageCount);
-
-    int curFilename = 0;
-    iXY maxSize(0, 0);
-
-    if ((hFile = _findfirst(pathWild, &myFile)) != ((int*) -1)) {
-        do {
-            sprintf(strBuf, "%s%s", path, myFile.name);
-            filenames[curFilename].setName(strBuf);
-            curFilename++;
+    iXY maxSize;
+    for(char** file = list; *file != 0; file++) {
+       std::string name = path;
+       name += *file;
+       if(name.find(".til") != std::string::npos) {
+           filenames.push_back(name);
 
             // Get the max image size.
-            if (!tempSurface.loadTIL(strBuf)) {
+            if (!tempSurface.loadTIL(name.c_str())) {
                 throw Exception("ERROR: This should not happen!");
             }
             if (maxSize.x < tempSurface.getPix().x) {
@@ -2875,23 +2858,23 @@
             if (maxSize.y < tempSurface.getPix().y) {
                 maxSize.y = tempSurface.getPix().y;
             }
-
-        } while (_findnext(hFile, &myFile) == 0);
+       }
     }
-    _findclose(hFile);
 
-    filenames.sort(FilenameSortFunction);
+    FileSystem::freeList(list);
+
+    std::sort(filenames.begin(), filenames.end());
 
     // Create the Surface to have the size of the largest image in the
     // diRectory.  All other images will be centered based off the
     // largest size.
-    create(maxSize, maxSize.x, imageCount);
+    create(maxSize, maxSize.x, filenames.size());
 
     // Now load in the sorted TIL names.
-    for (int i = 0; i < imageCount; i++) {
+    for (size_t i = 0; i < filenames.size(); i++) {
         setFrame(i);
 
-        if (!tempSurface.loadTIL(filenames[i].name)) {
+        if (!tempSurface.loadTIL(filenames[i].c_str())) {
             return 0;
         } else {
             iXY myOffset;
@@ -2905,138 +2888,46 @@
     return 1;
 } // end loadAllTILInDirectory
 
-// loadAllPCXInDirectory
-//---------------------------------------------------------------------------
-int Surface::loadAllPCXInDirectory(const char *path)
-{
-    char strBuf[256];
-    char pathWild[256];
-
-    sprintf(pathWild, "%s*.pcx", path);
-
-    int imageCount = UtilInterface::getNumFilesInDirectory(pathWild);
-    if (imageCount <= 0) {
-        return 0;
-    }
-
-    struct _finddata_t myFile;
-    int* hFile;
-
-    _findfirst(pathWild, &myFile);
-
-    // Find the dimensions of the first file.
-    Surface tempSurface;
-
-    cGrowList <Filename> filenames;
-    filenames.setNum(imageCount);
-
-    int curFilename = 0;
-    iXY maxSize(0, 0);
-
-    if ((hFile = _findfirst(pathWild, &myFile)) != ((int*) -1)) {
-        do {
-            sprintf(strBuf, "%s%s", path, myFile.name);
-            filenames[curFilename].setName(strBuf);
-            curFilename++;
-
-            // Get the max image size.
-            tempSurface.loadPCX(strBuf);
-
-            if (maxSize.x < tempSurface.getPix().x) {
-                maxSize.x = tempSurface.getPix().x;
-            }
-            if (maxSize.y < tempSurface.getPix().y) {
-                maxSize.y = tempSurface.getPix().y;
-            }
-
-        } while (_findnext(hFile, &myFile) == 0);
-    }
-    _findclose(hFile);
-
-    filenames.sort(FilenameSortFunction);
-
-    // Create the Surface to have the size of the largest image in the
-    // diRectory.  All other images will be centered based off the
-    // largest size.
-    create(maxSize, maxSize.x, imageCount);
-
-    // Now load in the sorted TIL names.
-    for (int i = 0; i < imageCount; i++) {
-        setFrame(i);
-
-        tempSurface.loadPCX(filenames[i].name);
-
-        iXY myOffset;
-        myOffset = maxSize - tempSurface.getPix();
-
-        fill(Color::black);
-        tempSurface.blt(*this, myOffset);
-    }
-
-    return 1;
-} // end loadAllPCXInDirectory
-
 // loadAllBMPInDirectory
 //---------------------------------------------------------------------------
 int Surface::loadAllBMPInDirectory(const char *path)
 {
-    char strBuf[256];
-    char pathWild[256];
-
-    sprintf(pathWild, "%s*.bmp", path);
-
-    int imageCount = UtilInterface::getNumFilesInDirectory(pathWild);
-    if (imageCount <= 0) {
-        return 0;
-    }
-
-    struct _finddata_t myFile;
-    int* hFile;
-
-    _findfirst(pathWild, &myFile);
-
-    // Find the dimensions of the first file.
+    char** list = FileSystem::enumerateFiles(path);
+    
+    std::vector<std::string> filenames;
     Surface tempSurface;
-
-    cGrowList <Filename> filenames;
-    filenames.setNum(imageCount);
-
-    int curFilename = 0;
-    iXY maxSize(0, 0);
-
-    if ((hFile = _findfirst(pathWild, &myFile)) != ((int*) -1)) {
-        do {
-            sprintf(strBuf, "%s%s", path, myFile.name);
-            filenames[curFilename].setName(strBuf);
-            curFilename++;
+    iXY maxSize;
+    for(char** file = list; *file != 0; file++) {
+       std::string name = path;
+       name += *file;
+       if(name.find(".til") != std::string::npos) {
+           filenames.push_back(name);
 
             // Get the max image size.
-            tempSurface.loadBMP(strBuf);
-
+            tempSurface.loadBMP(name.c_str());
             if (maxSize.x < tempSurface.getPix().x) {
                 maxSize.x = tempSurface.getPix().x;
             }
             if (maxSize.y < tempSurface.getPix().y) {
                 maxSize.y = tempSurface.getPix().y;
             }
-
-        } while (_findnext(hFile, &myFile) == 0);
+       }
     }
-    _findclose(hFile);
 
-    filenames.sort(FilenameSortFunction);
+    FileSystem::freeList(list);
+
+    std::sort(filenames.begin(), filenames.end());
 
     // Create the Surface to have the size of the largest image in the
     // diRectory.  All other images will be centered based off the
     // largest size.
-    create(maxSize, maxSize.x, imageCount);
+    create(maxSize, maxSize.x, filenames.size());
 
     // Now load in the sorted TIL names.
-    for (int i = 0; i < imageCount; i++) {
+    for (size_t i = 0; i < filenames.size(); i++) {
         setFrame(i);
 
-        tempSurface.loadBMP(filenames[i].name);
-
+        tempSurface.loadBMP(filenames[i].c_str());
         iXY myOffset;
         myOffset = maxSize - tempSurface.getPix();
 
@@ -3046,56 +2937,6 @@
 
     return 1;
 } // end loadAllBMPInDirectory
-
-// loadAllRAWInDirectory
-//---------------------------------------------------------------------------
-int Surface::loadAllRAWInDirectory(const char *path, const iXY &pix)
-{
-    char strBuf[256];
-    char pathWild[256];
-
-    sprintf(pathWild, "%s*.raw", path);
-
-    int imageCount = UtilInterface::getNumFilesInDirectory(pathWild);
-    if (imageCount <= 0) {
-        return 0;
-    }
-
-    struct _finddata_t myFile;
-    int* hFile;
-
-    _findfirst(pathWild, &myFile);
-
-    create(pix.x, pix.y, pix.x, imageCount);
-
-    cGrowList <Filename> filenames;
-    filenames.setNum(imageCount);
-
-    int curFilename = 0;
-
-    // Load up all the frames of the smoke.
-    if ((hFile = _findfirst(pathWild, &myFile)) != ((int*) -1)) {
-        do {
-            sprintf(strBuf, "%s%s", path, myFile.name);
-            filenames[curFilename].setName(strBuf);
-            curFilename++;
-        } while (_findnext(hFile, &myFile) == 0);
-    }
-    _findclose(hFile);
-
-    filenames.sort(FilenameSortFunction);
-
-    // Now load in the sorted RAW names.
-    for (int i = 0; i < imageCount; i++) {
-        setFrame(i);
-
-        if (!loadRAW(filenames[i].name, pix)) {
-            return 0;
-        }
-    }
-
-    return 1;
-} // end loadAllRAWInDirectory
 
 // initFont
 //---------------------------------------------------------------------------
Index: netpanzer/src/Lib/2D/Surface.hpp
diff -u netpanzer/src/Lib/2D/Surface.hpp:1.10 
netpanzer/src/Lib/2D/Surface.hpp:1.11
--- netpanzer/src/Lib/2D/Surface.hpp:1.10       Tue Sep 16 16:16:09 2003
+++ netpanzer/src/Lib/2D/Surface.hpp    Fri Sep 19 11:22:30 2003
@@ -515,9 +515,7 @@
     void setToBrightnessIndexes128();
     void bltAdd(const Surface &dest, iXY min) const;
     int  loadAllTILInDirectory(const char *path);
-    int  loadAllPCXInDirectory(const char *path);
     int  loadAllBMPInDirectory(const char *path);
-    int  loadAllRAWInDirectory(const char *path, const iXY &pix);
 
     // Blit a single character of text.
     void bltChar8x8(const iXY &pos, const char &character, const PIX &color) 
const;
Index: netpanzer/src/Lib/FileSystem.hpp
diff -u netpanzer/src/Lib/FileSystem.hpp:1.6 
netpanzer/src/Lib/FileSystem.hpp:1.7
--- netpanzer/src/Lib/FileSystem.hpp:1.6        Tue Sep 16 16:16:09 2003
+++ netpanzer/src/Lib/FileSystem.hpp    Fri Sep 19 11:22:30 2003
@@ -53,6 +53,8 @@
 
 //---------------------------------------------------------------------------
 
+class FileSystem;
+
 class ReadFile : public File
 {
 public:
Index: netpanzer/src/Lib/Interfaces/UtilInterface.cpp
diff -u netpanzer/src/Lib/Interfaces/UtilInterface.cpp:1.9 
netpanzer/src/Lib/Interfaces/UtilInterface.cpp:1.10
--- netpanzer/src/Lib/Interfaces/UtilInterface.cpp:1.9  Tue Sep 16 16:16:09 2003
+++ netpanzer/src/Lib/Interfaces/UtilInterface.cpp      Fri Sep 19 11:22:30 2003
@@ -22,6 +22,7 @@
 #include "SplitPath.hpp"
 #include "FindFirst.hpp"
 #include "Exception.hpp"
+#include "FileSystem.hpp"
 #include "UtilInterface.hpp"
 
 bool gSpanBlittingFlag = false;
@@ -82,36 +83,28 @@
 //---------------------------------------------------------------------------
 // Purpose: Returns file size, in bytes, or 0 if file not found.
 //---------------------------------------------------------------------------
-DWORD UtilInterface::getFileSize(String filename)
+size_t UtilInterface::getFileSize(String filename)
 {
-    struct stat filestats;
-    if (stat(filename, &filestats) < 0)
-        return 0;
+    ReadFile* file = FileSystem::openRead(filename);
+    size_t size = file->length();
+    delete file;
 
-    return (DWORD) filestats.st_size;
+    return size;
 } // end UtilInterface::getFileSize
 
 // getNumFilesInDirectory
 //---------------------------------------------------------------------------
 // Purpose: Returns the number of files in the specified directory.
 //---------------------------------------------------------------------------
-DWORD UtilInterface::getNumFilesInDirectory(String path)
+int UtilInterface::getNumFilesInDirectory(String path)
 {
-    struct _finddata_t myFile;
-    int* hFile;
+    char** list = FileSystem::enumerateFiles(path);
+    int numfiles=0;
+    for(char** file = list; *file != 0; file++)
+       numfiles++;
+    FileSystem::freeList(list);
 
-    DWORD numFiles = 0;
-
-    // Figure out how many files are in the directory.
-    if ((hFile = _findfirst((const char *) path, &myFile)) != ((int*) -1)) {
-        do {
-            numFiles++;
-
-        } while (_findnext(hFile, &myFile) == 0);
-        _findclose(hFile);
-    }
-
-    return numFiles;
+    return numfiles;
 } // end UtilInterface::getNumFilesInDirectory
 
 // deleteFile
Index: netpanzer/src/Lib/Interfaces/UtilInterface.hpp
diff -u netpanzer/src/Lib/Interfaces/UtilInterface.hpp:1.5 
netpanzer/src/Lib/Interfaces/UtilInterface.hpp:1.6
--- netpanzer/src/Lib/Interfaces/UtilInterface.hpp:1.5  Tue Sep 16 16:16:09 2003
+++ netpanzer/src/Lib/Interfaces/UtilInterface.hpp      Fri Sep 19 11:22:30 2003
@@ -53,13 +53,10 @@
     static String getFilename(String path);
     static String getExtension(String path);
     static void   deleteFile(String path);
-    static DWORD  getFileSize(String filename);
-    static DWORD  getNumFilesInDirectory(String path);
+    static size_t getFileSize(String filename);
+    static int    getNumFilesInDirectory(String path);
     static void   checkError(FILE *fp);
     static void   startRandomNumberGenerator();
-
-}
-; // end UtilInterface
-
+}; // end UtilInterface
 
 #endif // __UtilInterface_hpp__
Index: netpanzer/src/Lib/optionmm/command_line.hpp
diff -u netpanzer/src/Lib/optionmm/command_line.hpp:1.2 
netpanzer/src/Lib/optionmm/command_line.hpp:1.3
--- netpanzer/src/Lib/optionmm/command_line.hpp:1.2     Tue Sep 16 16:16:11 2003
+++ netpanzer/src/Lib/optionmm/command_line.hpp Fri Sep 19 11:22:30 2003
@@ -1,5 +1,5 @@
 //
-// $Id: command_line.hpp,v 1.2 2003/09/16 20:16:11 fidlej Exp $
+// $Id: command_line.hpp,v 1.3 2003/09/19 15:22:30 MatzeBraun Exp $
 //
 //  optionmm::command_line
 //  Copyright (C) 2002 Christian Holm Christensen <address@hidden>
@@ -33,19 +33,7 @@
 #ifndef __IOSTREAM__
 #include <iostream>
 #endif
-#ifdef WIN32
-# ifdef LIBOPTIONMM_EXPORTS
-#  ifndef EXPORT
-#   define EXPORT __declspec(dllexport)
-#  endif
-# else
-#  ifndef EXPORT
-#   define EXPORT __declspec(dllimport)
-#  endif
-# endif
-#else
-# define EXPORT
-#endif
+#define EXPORT
 
 /** @file   command_line.hh
     @author Christian Holm
Index: netpanzer/src/Makefile
diff -u netpanzer/src/Makefile:1.15 netpanzer/src/Makefile:1.16
--- netpanzer/src/Makefile:1.15 Sat Sep 13 18:38:20 2003
+++ netpanzer/src/Makefile      Fri Sep 19 11:22:30 2003
@@ -20,7 +20,7 @@
 
 GOAL = ../netpanzer
 LINKFLAGS += -g3 `sdl-config --libs` -lSDL_net -lSDL_mixer -lSDL_image -lphysfs
-CFLAGS += `sdl-config --cflags` -DUNIX
+CFLAGS += `sdl-config --cflags` -D${SYSTEM}
 
 ifeq ($(PROFILING),yes)
 CFLAGS += -pg
Index: netpanzer/src/configure
diff -u netpanzer/src/configure:1.3 netpanzer/src/configure:1.4
--- netpanzer/src/configure:1.3 Sun Sep  7 15:09:59 2003
+++ netpanzer/src/configure     Fri Sep 19 11:22:30 2003
@@ -3,7 +3,7 @@
 # pseudo configure, until we use autoconf...
 
 echo -n "Checking for system type... "
-if uname | grep "win"; then
+if uname | grep -i "win"; then
        echo "assuming win32"
        OS=WIN32
 else




reply via email to

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