Changeset 197

Show
Ignore:
Timestamp:
02/24/08 22:17:23 (4 months ago)
Author:
timo
Message:

added file copy tree for the game packs - lists supported games

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • GtkRadiant/branches/ZeroRadiant/config.py

    r195 r197  
    232232                        env.Append( CPPDEFINES = [ '_DEBUG' ] )                          
    233233                else: 
    234                         env.Append( CFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations' ] ) 
    235                         env.Append( CXXFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations' ] ) 
     234                        env.Append( CFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations', '-fno-strict-aliasing' ] ) 
     235                        env.Append( CXXFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations','-fno-strict-aliasing' ] ) 
    236236                        #env.Append( CFLAGS = [ '-march=pentium3' ] ) 
    237237 
  • GtkRadiant/branches/ZeroRadiant/libs/missing.h

    r183 r197  
    6868int GetFullPathName(const char *lpFileName, int nBufferLength, char *lpBuffer, char **lpFilePart); 
    6969bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName); 
     70bool CopyTree( const char* source, const char* dest ); 
    7071 
    7172#ifndef APIENTRY 
  • GtkRadiant/branches/ZeroRadiant/radiant/brush.cpp

    r185 r197  
    15351535void Brush_MakeSided (int sides) 
    15361536{ 
    1537         int             i, axis
     1537        int             i, axis = 0
    15381538        vec3_t  mins, maxs; 
    15391539        brush_t *b; 
  • GtkRadiant/branches/ZeroRadiant/radiant/camwindow.cpp

    r185 r197  
    12721272  float screenaspect; 
    12731273  float yfov; 
    1274   double        start, end; 
     1274  double        start = 0.0, end; 
    12751275  int           i; 
    12761276 
  • GtkRadiant/branches/ZeroRadiant/radiant/dialog.cpp

    r192 r197  
    9595    g_object_set_data (G_OBJECT (m_pWidget), "ret", &m_nReturn); 
    9696 
    97     BuildDialog (); 
     97    BuildDialog(); 
    9898    m_bNeedBuild = false; 
    9999  } 
  • GtkRadiant/branches/ZeroRadiant/radiant/filters.cpp

    r185 r197  
    138138                || !strncmp( pb->owner->eclass->name, "trigger", 7) ) && !pb->patchBrush ) 
    139139        { 
    140                 bool filterbrush
     140                bool filterbrush = false
    141141                for (face_t *f=pb->brush_faces;f!=NULL;f = f->next) 
    142142                { 
  • GtkRadiant/branches/ZeroRadiant/radiant/missing.cpp

    r185 r197  
    4040#include <unistd.h> 
    4141#include <sys/time.h> 
     42#include <sys/types.h> 
     43#include <sys/stat.h> 
    4244#include <stdlib.h> 
     45#include <dirent.h> 
    4346#include "missing.h" 
     47#include "qsysprintf.h" 
    4448 
    4549bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName) 
     
    4751  FILE *src, *dst; 
    4852  void* buf; 
    49   int l, ret = 0; 
     53  int l; 
     54  bool ret = false; 
    5055  char realsrc[PATH_MAX], realdest[PATH_MAX]; 
    5156 
     
    5459 
    5560  src = fopen (realsrc, "rb"); 
    56   if (!src) 
    57     return 0; 
     61  if ( !src ) { 
     62    return false; 
     63  } 
    5864  dst = fopen (realdest, "wb"); 
    59   if (!dst) 
    60   { 
     65  if (!dst) { 
    6166    fclose (src); 
    62     return 0
     67    return false
    6368  } 
    6469  
     
    7176    if (fread (buf, l, 1, src) == 1) 
    7277      if (fwrite (buf, l, 1, dst) == 1) 
    73         ret = 1
     78        ret = true
    7479 
    7580  g_free (buf); 
     
    7883 
    7984  return ret; 
     85} 
     86 
     87bool CreateDirectory( const char *directory ) { 
     88        if ( mkdir( directory, 0777 ) == -1 ) { 
     89                Sys_Printf( "mkdir %s failed\n", directory ); 
     90                return false; 
     91        } 
     92        return true; 
     93} 
     94 
     95bool CopyTree( const char *source, const char *dest ) { 
     96        DIR                             *dir; 
     97        struct dirent   *dirlist; 
     98        struct stat             sbuf; 
     99        Str                             srcEntry; 
     100        Str                             dstEntry; 
     101 
     102        dir = opendir( source ); 
     103        if ( dir != NULL ) { 
     104                while ( ( dirlist = readdir( dir ) ) != NULL ) { 
     105                        if ( strcmp( dirlist->d_name, "." ) == 0 || strcmp( dirlist->d_name, ".." ) == 0 ) { 
     106                                continue; 
     107                        } 
     108                        if ( strcmp( dirlist->d_name, ".svn" ) == 0 ) { 
     109                                continue; 
     110                        } 
     111                        srcEntry = source; 
     112                        srcEntry += "/"; 
     113                        srcEntry += dirlist->d_name; 
     114                        dstEntry = dest; 
     115                        dstEntry += "/"; 
     116                        dstEntry += dirlist->d_name; 
     117                        if ( stat( srcEntry.GetBuffer(), &sbuf ) == -1 ) { 
     118                                Sys_Printf( "stat %s failed\n", srcEntry.GetBuffer() ); 
     119                        } 
     120                        if ( S_ISDIR( sbuf.st_mode ) ) { 
     121                                bool ret; 
     122                                if ( stat( dstEntry.GetBuffer(), &sbuf ) == -1 ) { 
     123                                        ret = CreateDirectory( dstEntry.GetBuffer() ); 
     124                                } 
     125                                ret = CopyTree( srcEntry.GetBuffer(), dstEntry.GetBuffer() ); 
     126                                if ( !ret ) { 
     127                                        return false; 
     128                                } 
     129                        } else { 
     130                                Sys_Printf( "copy %s -> %s\n", srcEntry.GetBuffer(), dstEntry.GetBuffer() ); 
     131                                bool ret = CopyFile( srcEntry.GetBuffer(), dstEntry.GetBuffer() ); 
     132                                if ( !ret ) { 
     133                                        return false; 
     134                                } 
     135                        } 
     136                } 
     137                closedir( dir ); 
     138        } 
     139        return true; 
    80140} 
    81141 
     
    117177  return strlen (lpBuffer); 
    118178} 
    119 /* 
    120 static void g_string_sprintfa_int (GString *string, const gchar *fmt, va_list args) 
    121 { 
    122   gchar *buffer; 
    123  
    124   buffer = g_strdup_vprintf (fmt, args); 
    125   g_string_append (string, buffer); 
    126   g_free (buffer); 
    127 } 
    128  
    129 const CString& CString::operator=(const char* lpsz) 
    130 { 
    131   g_string_assign (m_str, lpsz); 
    132   return *this; 
    133 } 
    134  
    135 const CString& CString::operator+=(const char* lpsz) 
    136 { 
    137   g_string_append (m_str, lpsz); 
    138   return *this; 
    139 } 
    140  
    141 CString::operator char*() const 
    142 {  
    143   return m_str->str; 
    144 } 
    145  
    146 void CString::Format(const char* fmt, ...) 
    147 { 
    148   va_list args; 
    149   
    150   g_string_truncate (m_str, 0); 
    151   
    152   va_start (args, fmt); 
    153   g_string_sprintfa_int (m_str, fmt, args); 
    154   va_end (args); 
    155 } 
    156  
    157 CString CString::Right(int nCount) const 
    158 { 
    159   if (nCount < 0) 
    160     nCount = 0; 
    161   else if (nCount > m_str->len) 
    162     nCount = m_str->len; 
    163  
    164   CString dest (&m_str->str[m_str->len-nCount]); 
    165   return dest; 
    166 } 
    167  
    168 CString CString::Left(int nCount) const 
    169 { 
    170   if (nCount < 0) 
    171     nCount = 0; 
    172   else if (nCount > m_str->len) 
    173     nCount = m_str->len; 
    174  
    175   CString dest; 
    176   dest.m_str = g_string_sized_new (nCount); 
    177   memcpy (dest.m_str->str, m_str->str, nCount); 
    178   dest.m_str->str[nCount] = 0; 
    179   return dest; 
    180 } 
    181  
    182 void CString::SetAt(int nIndex, char ch) 
    183 { 
    184   if (nIndex >= 0 && nIndex < m_str->len) 
    185     m_str->str[nIndex] = ch; 
    186 } 
    187  
    188 char CString::GetAt(int nIndex) const 
    189 { 
    190   if (nIndex >= 0 && nIndex < m_str->len) 
    191     return m_str->str[nIndex]; 
    192   return 0; 
    193 } 
    194  
    195 char CString::operator[](int nIndex) const 
    196 { 
    197   if (nIndex >= 0 && nIndex < m_str->len) 
    198     return m_str->str[nIndex]; 
    199   return 0; 
    200 } 
    201 */ 
    202179 
    203180#endif 
  • GtkRadiant/branches/ZeroRadiant/radiant/preferences.cpp

    r192 r197  
    31233123*/ 
    31243124 
     3125CGameInstall::CGameInstall() { 
     3126        memset( m_availGames, 0, sizeof( m_availGames ) ); 
     3127} 
     3128 
    31253129void CGameInstall::BuildDialog() { 
    31263130        GtkWidget *dlg, *vbox1, *button, *text, *combo, *entry; 
     
    31423146 
    31433147        GList *combo_list = NULL; 
    3144         combo_list = g_list_append( combo_list, "Quake III Arena and mods" ); 
    3145         combo_list = g_list_append( combo_list, "Urban Terror standalone" ); 
    3146         combo_list = g_list_append( combo_list, "Warsaw" ); 
     3148        int iGame = 0; 
     3149        while ( m_availGames[ iGame ] != GAME_NONE ) { 
     3150                switch ( m_availGames[ iGame ] ) { 
     3151                case GAME_Q3: 
     3152                        combo_list = g_list_append( combo_list, "Quake III Arena (including mods)" ); 
     3153                        break; 
     3154                case GAME_URT: 
     3155                        combo_list = g_list_append( combo_list, "Urban Terror (standalone)" ); 
     3156                        break; 
     3157                case GAME_WARSOW: 
     3158                        combo_list = g_list_append( combo_list, "Warsow" ); 
     3159                        break; 
     3160                } 
     3161                iGame++; 
     3162        } 
    31473163        gtk_combo_set_popdown_strings( GTK_COMBO( combo ), combo_list ); 
    31483164        g_list_free( combo_list ); 
     
    31883204 
    31893205void CGameInstall::Run() { 
     3206        ScanGames(); 
    31903207        DoModal(); 
    31913208        Sys_Printf( "combo: %d name: %s engine: %s mod: %s\n", m_nComboSelect, m_strName.GetBuffer(), m_strEngine.GetBuffer(), m_strMod.GetBuffer() ); 
     
    32063223        fprintf( fg, "  gametools=\"%sgames\"\n", g_strAppPath.GetBuffer() ); 
    32073224        fprintf( fg, "  enginepath=\"%s\"\n", m_strEngine.GetBuffer() ); 
    3208         switch ( m_nComboSelect ) { 
    3209         case GAME_Q3: 
     3225        switch ( m_availGames[ m_nComboSelect ] ) { 
     3226        case GAME_Q3: { 
     3227                Str source = g_strAppPath.GetBuffer(); 
     3228                source += "installs/"; 
     3229                source += Q3_PACK; 
     3230                Str dest = m_strEngine.GetBuffer(); 
     3231                CopyTree( source.GetBuffer(), dest.GetBuffer() ); 
    32103232                fprintf( fg, "  basegame=\"baseq3\"\n" ); 
    32113233                break; 
    3212         case GAME_URT: 
     3234        } 
     3235        case GAME_URT: { 
     3236                Str source = g_strAppPath.GetBuffer(); 
     3237                source += "installs/"; 
     3238                source += URT_PACK; 
     3239                Str dest = m_strEngine.GetBuffer(); 
     3240                CopyTree( source.GetBuffer(), dest.GetBuffer() ); 
    32133241                fprintf( fg, "  basegame=\"q3ut4\"\n" ); 
    32143242                break; 
     3243        } 
    32153244        case GAME_WARSOW: 
    32163245                fprintf( fg, "  basegame=\"basewsw\"\n" ); 
     
    32203249        fclose( fg ); 
    32213250} 
     3251 
     3252/* 
     3253=============== 
     3254CGameInstall::ScanGames 
     3255scan for active games that can be installed, based on the presence  
     3256=============== 
     3257*/ 
     3258void CGameInstall::ScanGames() { 
     3259        Str                             pakPaths = g_strAppPath.GetBuffer(); 
     3260        DIR                             *dir; 
     3261        struct dirent   *dirlist; 
     3262        int                             iGame = 0; 
     3263 
     3264        pakPaths +=     "installs/"; 
     3265        dir = opendir( pakPaths.GetBuffer() ); 
     3266        if ( dir != NULL ) { 
     3267                while ( ( dirlist = readdir( dir ) ) != NULL ) { 
     3268                        if ( stricmp( dirlist->d_name, Q3_PACK ) == 0 ) { 
     3269                                m_availGames[ iGame++ ] = GAME_Q3; 
     3270                        } 
     3271                        if ( stricmp( dirlist->d_name, URT_PACK ) == 0 ) { 
     3272                                m_availGames[ iGame++ ] = GAME_URT; 
     3273                        } 
     3274                } 
     3275                closedir( dir ); 
     3276        } 
     3277} 
  • GtkRadiant/branches/ZeroRadiant/radiant/preferences.h

    r192 r197  
    197197select games, copy editing assets and write out configuration files 
    198198 */ 
     199 
     200#define Q3_PACK "Q3Pack" 
     201#define URT_PACK "UrTPack" 
     202 
    199203class CGameInstall : public Dialog { 
    200204public: 
     205        CGameInstall(); 
     206        void ScanGames(); 
    201207        void Run(); 
    202208        void BuildDialog(); 
    203209 
    204210        enum gameType_e { 
    205                 GAME_Q3, 
     211                GAME_NONE = 0, 
     212                GAME_Q3 = 1, 
    206213                GAME_URT, 
    207                 GAME_WARSOW 
     214                GAME_WARSOW, 
     215                GAME_COUNT 
    208216        }; 
    209217 
    210218protected: 
    211         Str m_strName; 
    212         Str     m_strMod; 
    213         Str m_strEngine; 
    214         int m_nComboSelect; 
     219        Str             m_strName; 
     220        Str             m_strMod; 
     221        Str             m_strEngine; 
     222        int             m_nComboSelect; 
     223 
     224        // maps from m_nComboSelect to the games 
     225        int     m_availGames[GAME_COUNT]; 
    215226}; 
    216227