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

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/ZeroRadiant@197 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
TTimo 2008-02-25 04:17:23 +00:00
parent a06f65b042
commit 051578cb3b
58 changed files with 153 additions and 108 deletions

View file

@ -231,8 +231,8 @@ class Config:
env.Append( CXXFLAGS = [ '-g' ] )
env.Append( CPPDEFINES = [ '_DEBUG' ] )
else:
env.Append( CFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations' ] )
env.Append( CXXFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations' ] )
env.Append( CFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations', '-fno-strict-aliasing' ] )
env.Append( CXXFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations','-fno-strict-aliasing' ] )
#env.Append( CFLAGS = [ '-march=pentium3' ] )
# env.Append( LINKFLAGS = [ '-m32' ] )

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View file

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View file

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View file

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 630 B

After

Width:  |  Height:  |  Size: 630 B

View file

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 293 KiB

After

Width:  |  Height:  |  Size: 293 KiB

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 126 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View file

Before

Width:  |  Height:  |  Size: 614 B

After

Width:  |  Height:  |  Size: 614 B

View file

Before

Width:  |  Height:  |  Size: 614 B

After

Width:  |  Height:  |  Size: 614 B

View file

Before

Width:  |  Height:  |  Size: 614 B

After

Width:  |  Height:  |  Size: 614 B

View file

Before

Width:  |  Height:  |  Size: 614 B

After

Width:  |  Height:  |  Size: 614 B

View file

@ -67,6 +67,7 @@ inline int GetPrivateProfileInt(char* a, char* b, int i, char* c) { return i; };
#define VERIFY(a) a;
int GetFullPathName(const char *lpFileName, int nBufferLength, char *lpBuffer, char **lpFilePart);
bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName);
bool CopyTree( const char* source, const char* dest );
#ifndef APIENTRY
#define APIENTRY

View file

@ -1534,7 +1534,7 @@ Makes the current brush have the given number of 2d sides
*/
void Brush_MakeSided (int sides)
{
int i, axis;
int i, axis = 0;
vec3_t mins, maxs;
brush_t *b;
texdef_t *texdef;

View file

@ -1271,7 +1271,7 @@ void CamWnd::Cam_Draw()
face_t *face;
float screenaspect;
float yfov;
double start, end;
double start = 0.0, end;
int i;
if (!active_brushes.next)

View file

@ -94,7 +94,7 @@ void Dialog::Create ()
g_object_set_data (G_OBJECT (m_pWidget), "loop", &m_nLoop);
g_object_set_data (G_OBJECT (m_pWidget), "ret", &m_nReturn);
BuildDialog ();
BuildDialog();
m_bNeedBuild = false;
}
}

View file

@ -137,7 +137,7 @@ bool FilterBrush(brush_t *pb)
|| !strncmp( pb->owner->eclass->name, "func", 4)
|| !strncmp( pb->owner->eclass->name, "trigger", 7) ) && !pb->patchBrush )
{
bool filterbrush;
bool filterbrush = false;
for (face_t *f=pb->brush_faces;f!=NULL;f = f->next)
{
filterbrush=false;

View file

@ -39,27 +39,32 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <dirent.h>
#include "missing.h"
#include "qsysprintf.h"
bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName)
{
FILE *src, *dst;
void* buf;
int l, ret = 0;
int l;
bool ret = false;
char realsrc[PATH_MAX], realdest[PATH_MAX];
realpath (lpExistingFileName, realsrc);
realpath (lpNewFileName, realdest);
src = fopen (realsrc, "rb");
if (!src)
return 0;
if ( !src ) {
return false;
}
dst = fopen (realdest, "wb");
if (!dst)
{
if (!dst) {
fclose (src);
return 0;
return false;
}
fseek (src, 0, SEEK_END);
@ -70,7 +75,7 @@ bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName)
if (buf != NULL)
if (fread (buf, l, 1, src) == 1)
if (fwrite (buf, l, 1, dst) == 1)
ret = 1;
ret = true;
g_free (buf);
fclose (src);
@ -79,6 +84,61 @@ bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName)
return ret;
}
bool CreateDirectory( const char *directory ) {
if ( mkdir( directory, 0777 ) == -1 ) {
Sys_Printf( "mkdir %s failed\n", directory );
return false;
}
return true;
}
bool CopyTree( const char *source, const char *dest ) {
DIR *dir;
struct dirent *dirlist;
struct stat sbuf;
Str srcEntry;
Str dstEntry;
dir = opendir( source );
if ( dir != NULL ) {
while ( ( dirlist = readdir( dir ) ) != NULL ) {
if ( strcmp( dirlist->d_name, "." ) == 0 || strcmp( dirlist->d_name, ".." ) == 0 ) {
continue;
}
if ( strcmp( dirlist->d_name, ".svn" ) == 0 ) {
continue;
}
srcEntry = source;
srcEntry += "/";
srcEntry += dirlist->d_name;
dstEntry = dest;
dstEntry += "/";
dstEntry += dirlist->d_name;
if ( stat( srcEntry.GetBuffer(), &sbuf ) == -1 ) {
Sys_Printf( "stat %s failed\n", srcEntry.GetBuffer() );
}
if ( S_ISDIR( sbuf.st_mode ) ) {
bool ret;
if ( stat( dstEntry.GetBuffer(), &sbuf ) == -1 ) {
ret = CreateDirectory( dstEntry.GetBuffer() );
}
ret = CopyTree( srcEntry.GetBuffer(), dstEntry.GetBuffer() );
if ( !ret ) {
return false;
}
} else {
Sys_Printf( "copy %s -> %s\n", srcEntry.GetBuffer(), dstEntry.GetBuffer() );
bool ret = CopyFile( srcEntry.GetBuffer(), dstEntry.GetBuffer() );
if ( !ret ) {
return false;
}
}
}
closedir( dir );
}
return true;
}
int GetFullPathName(const char *lpFileName, int nBufferLength, char *lpBuffer, char **lpFilePart)
{
if (lpFileName[0] == '/')
@ -116,88 +176,5 @@ int GetFullPathName(const char *lpFileName, int nBufferLength, char *lpBuffer, c
return strlen (lpBuffer);
}
/*
static void g_string_sprintfa_int (GString *string, const gchar *fmt, va_list args)
{
gchar *buffer;
buffer = g_strdup_vprintf (fmt, args);
g_string_append (string, buffer);
g_free (buffer);
}
const CString& CString::operator=(const char* lpsz)
{
g_string_assign (m_str, lpsz);
return *this;
}
const CString& CString::operator+=(const char* lpsz)
{
g_string_append (m_str, lpsz);
return *this;
}
CString::operator char*() const
{
return m_str->str;
}
void CString::Format(const char* fmt, ...)
{
va_list args;
g_string_truncate (m_str, 0);
va_start (args, fmt);
g_string_sprintfa_int (m_str, fmt, args);
va_end (args);
}
CString CString::Right(int nCount) const
{
if (nCount < 0)
nCount = 0;
else if (nCount > m_str->len)
nCount = m_str->len;
CString dest (&m_str->str[m_str->len-nCount]);
return dest;
}
CString CString::Left(int nCount) const
{
if (nCount < 0)
nCount = 0;
else if (nCount > m_str->len)
nCount = m_str->len;
CString dest;
dest.m_str = g_string_sized_new (nCount);
memcpy (dest.m_str->str, m_str->str, nCount);
dest.m_str->str[nCount] = 0;
return dest;
}
void CString::SetAt(int nIndex, char ch)
{
if (nIndex >= 0 && nIndex < m_str->len)
m_str->str[nIndex] = ch;
}
char CString::GetAt(int nIndex) const
{
if (nIndex >= 0 && nIndex < m_str->len)
return m_str->str[nIndex];
return 0;
}
char CString::operator[](int nIndex) const
{
if (nIndex >= 0 && nIndex < m_str->len)
return m_str->str[nIndex];
return 0;
}
*/
#endif

View file

@ -3122,6 +3122,10 @@ CGameInstall
============================================================
*/
CGameInstall::CGameInstall() {
memset( m_availGames, 0, sizeof( m_availGames ) );
}
void CGameInstall::BuildDialog() {
GtkWidget *dlg, *vbox1, *button, *text, *combo, *entry;
@ -3141,9 +3145,21 @@ void CGameInstall::BuildDialog() {
gtk_box_pack_start( GTK_BOX( vbox1 ), combo, FALSE, FALSE, 0 );
GList *combo_list = NULL;
combo_list = g_list_append( combo_list, "Quake III Arena and mods" );
combo_list = g_list_append( combo_list, "Urban Terror standalone" );
combo_list = g_list_append( combo_list, "Warsaw" );
int iGame = 0;
while ( m_availGames[ iGame ] != GAME_NONE ) {
switch ( m_availGames[ iGame ] ) {
case GAME_Q3:
combo_list = g_list_append( combo_list, "Quake III Arena (including mods)" );
break;
case GAME_URT:
combo_list = g_list_append( combo_list, "Urban Terror (standalone)" );
break;
case GAME_WARSOW:
combo_list = g_list_append( combo_list, "Warsow" );
break;
}
iGame++;
}
gtk_combo_set_popdown_strings( GTK_COMBO( combo ), combo_list );
g_list_free( combo_list );
AddDialogData( combo, &m_nComboSelect, DLG_COMBO_INT );
@ -3187,6 +3203,7 @@ void CGameInstall::BuildDialog() {
}
void CGameInstall::Run() {
ScanGames();
DoModal();
Sys_Printf( "combo: %d name: %s engine: %s mod: %s\n", m_nComboSelect, m_strName.GetBuffer(), m_strEngine.GetBuffer(), m_strMod.GetBuffer() );
@ -3205,13 +3222,25 @@ void CGameInstall::Run() {
fprintf( fg, " name=\"%s\"\n", m_strName.GetBuffer() );
fprintf( fg, " gametools=\"%sgames\"\n", g_strAppPath.GetBuffer() );
fprintf( fg, " enginepath=\"%s\"\n", m_strEngine.GetBuffer() );
switch ( m_nComboSelect ) {
case GAME_Q3:
switch ( m_availGames[ m_nComboSelect ] ) {
case GAME_Q3: {
Str source = g_strAppPath.GetBuffer();
source += "installs/";
source += Q3_PACK;
Str dest = m_strEngine.GetBuffer();
CopyTree( source.GetBuffer(), dest.GetBuffer() );
fprintf( fg, " basegame=\"baseq3\"\n" );
break;
case GAME_URT:
}
case GAME_URT: {
Str source = g_strAppPath.GetBuffer();
source += "installs/";
source += URT_PACK;
Str dest = m_strEngine.GetBuffer();
CopyTree( source.GetBuffer(), dest.GetBuffer() );
fprintf( fg, " basegame=\"q3ut4\"\n" );
break;
}
case GAME_WARSOW:
fprintf( fg, " basegame=\"basewsw\"\n" );
break;
@ -3219,3 +3248,30 @@ void CGameInstall::Run() {
fprintf( fg, "/>\n" );
fclose( fg );
}
/*
===============
CGameInstall::ScanGames
scan for active games that can be installed, based on the presence
===============
*/
void CGameInstall::ScanGames() {
Str pakPaths = g_strAppPath.GetBuffer();
DIR *dir;
struct dirent *dirlist;
int iGame = 0;
pakPaths += "installs/";
dir = opendir( pakPaths.GetBuffer() );
if ( dir != NULL ) {
while ( ( dirlist = readdir( dir ) ) != NULL ) {
if ( stricmp( dirlist->d_name, Q3_PACK ) == 0 ) {
m_availGames[ iGame++ ] = GAME_Q3;
}
if ( stricmp( dirlist->d_name, URT_PACK ) == 0 ) {
m_availGames[ iGame++ ] = GAME_URT;
}
}
closedir( dir );
}
}

View file

@ -196,15 +196,23 @@ public:
/*!
select games, copy editing assets and write out configuration files
*/
#define Q3_PACK "Q3Pack"
#define URT_PACK "UrTPack"
class CGameInstall : public Dialog {
public:
CGameInstall();
void ScanGames();
void Run();
void BuildDialog();
enum gameType_e {
GAME_Q3,
GAME_NONE = 0,
GAME_Q3 = 1,
GAME_URT,
GAME_WARSOW
GAME_WARSOW,
GAME_COUNT
};
protected:
@ -212,6 +220,9 @@ protected:
Str m_strMod;
Str m_strEngine;
int m_nComboSelect;
// maps from m_nComboSelect to the games
int m_availGames[GAME_COUNT];
};
/*!