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' ] )
#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
*/
void Brush_MakeSided (int sides)
{
- int i, axis;
+ int i, axis = 0;
vec3_t mins, maxs;
brush_t *b;
texdef_t *texdef;
face_t *face;
float screenaspect;
float yfov;
- double start, end;
+ double start = 0.0, end;
int i;
if (!active_brushes.next)
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;
}
}
|| !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;
#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);
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);
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] == '/')
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
============================================================
*/
+CGameInstall::CGameInstall() {
+ memset( m_availGames, 0, sizeof( m_availGames ) );
+}
+
void CGameInstall::BuildDialog() {
GtkWidget *dlg, *vbox1, *button, *text, *combo, *entry;
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 );
}
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() );
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;
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 );
+ }
+}
/*!
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:
- Str m_strName;
- Str m_strMod;
- Str m_strEngine;
- int m_nComboSelect;
+ Str m_strName;
+ Str m_strMod;
+ Str m_strEngine;
+ int m_nComboSelect;
+
+ // maps from m_nComboSelect to the games
+ int m_availGames[GAME_COUNT];
};
/*!