]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/camera/misc.cpp
uncrustify! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / contrib / camera / misc.cpp
index a279df06420d9e4d4f3489a4bc439c102ea5f599..1fe7509bc5a3f9b3ba01dd6e8104d910b691c8f4 100644 (file)
 /*
-Copyright (C) 1999-2007 id Software, Inc. and contributors.
-For a list of contributors, see the accompanying CONTRIBUTORS file.
+   Copyright (C) 1999-2007 id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
 
-This file is part of GtkRadiant.
+   This file is part of GtkRadiant.
 
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-GtkRadiant is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
 /*
-Camera plugin for GtkRadiant
-Copyright (C) 2002 Splash Damage Ltd.
-*/
+   Camera plugin for GtkRadiant
+   Copyright (C) 2002 Splash Damage Ltd.
+ */
 
 #include "camera.h"
 
-void Sys_ERROR( char* text, ... )
-{
-  va_list argptr;
-  char buf[32768];
+void Sys_ERROR( char* text, ... ){
+       va_list argptr;
+       char buf[32768];
 
-  va_start (argptr,text);
-  vsprintf (buf, text,argptr);
-  va_end (argptr);
+       va_start( argptr,text );
+       vsprintf( buf, text,argptr );
+       va_end( argptr );
 
-  Sys_Printf("Camera::ERROR->%s", buf);
+       Sys_Printf( "Camera::ERROR->%s", buf );
 }
 
-char* UnixToDosPath( char* path )
-{
+char* UnixToDosPath( char* path ){
 #ifndef _WIN32
        return path;
 #else
-       for(char* p = path; *p; p++)
+       for ( char* p = path; *p; p++ )
        {
-               if(*p == '/')
+               if ( *p == '/' ) {
                        *p = '\\';
+               }
        }
        return path;
 #endif
 }
 
-void CAMERA_ExtractFilePath( const char *path, char *dest )
-{
-  const char *src;
+void CAMERA_ExtractFilePath( const char *path, char *dest ){
+       const char *src;
 
-  src = path + strlen(path) - 1;
+       src = path + strlen( path ) - 1;
 
 //
 // back up until a \ or the start
 //
-  while (src != path && *(src-1) != '/' && *(src-1) != '\\')
-    src--;
+       while ( src != path && *( src - 1 ) != '/' && *( src - 1 ) != '\\' )
+               src--;
 
-  memcpy (dest, path, src-path);
-  dest[src-path] = 0;
+       memcpy( dest, path, src - path );
+       dest[src - path] = 0;
 }
 
-const char* ExtractFilename( const char* path )
-{
-       char* p = (char *)strrchr(path, '/');
-       if(!p)
-       {
-               p = (char *)strrchr(path, '\\');
+const char* ExtractFilename( const char* path ){
+       char* p = (char *)strrchr( path, '/' );
+       if ( !p ) {
+               p = (char *)strrchr( path, '\\' );
 
-               if(!p)
+               if ( !p ) {
                        return path;
+               }
        }
        return ++p;
 }
 
-int Q_stricmp (const char *s1, const char *s2) {
+int Q_stricmp( const char *s1, const char *s2 ) {
        return stricmp( s1, s2 );
 }
 
 /*
-==============
-FileExists
-==============
-*/
-bool FileExists (const char *filename)
-{
-       FILE    *f;
+   ==============
+   FileExists
+   ==============
+ */
+bool FileExists( const char *filename ){
+       FILE    *f;
 
        f = fopen( filename, "r" );
-       if( !f )
+       if ( !f ) {
                return false;
+       }
        fclose( f );
        return true;
 }
@@ -106,56 +103,53 @@ bool FileExists (const char *filename)
 // empty wrappers, don't really use them here
 //
 void Cbuf_AddText( const char *text ) {};
-void Cbuf_Execute (void) {};
+void Cbuf_Execute( void ) {};
 
 //
 // Common
 //
 
-void CDECL Com_Error( int level, const char *error, ... )
-{
-  va_list argptr;
-  char buf[32768];
+void CDECL Com_Error( int level, const char *error, ... ){
+       va_list argptr;
+       char buf[32768];
 
-  va_start (argptr,error);
-  vsprintf (buf, error,argptr);
-  va_end (argptr);
+       va_start( argptr,error );
+       vsprintf( buf, error,argptr );
+       va_end( argptr );
 
-  Sys_Printf("Camera::ERROR->%s", buf);
+       Sys_Printf( "Camera::ERROR->%s", buf );
 }
 
-void CDECL Com_Printf( const char* msg, ... )
-{
-  va_list argptr;
-  char buf[32768];
+void CDECL Com_Printf( const char* msg, ... ){
+       va_list argptr;
+       char buf[32768];
 
-  va_start (argptr,msg);
-  vsprintf (buf, msg,argptr);
-  va_end (argptr);
+       va_start( argptr,msg );
+       vsprintf( buf, msg,argptr );
+       va_end( argptr );
 
-  Sys_Printf("Camera::%s", buf);
+       Sys_Printf( "Camera::%s", buf );
 }
 
-void CDECL Com_DPrintf( const char* msg, ... )
-{
+void CDECL Com_DPrintf( const char* msg, ... ){
 #ifdef _DEBUG
-  va_list argptr;
-  char buf[32768];
+       va_list argptr;
+       char buf[32768];
 
-  va_start (argptr,msg);
-  vsprintf (buf, msg,argptr);
-  va_end (argptr);
+       va_start( argptr,msg );
+       vsprintf( buf, msg,argptr );
+       va_end( argptr );
 
-  Sys_Printf("Camera::%s", buf);
+       Sys_Printf( "Camera::%s", buf );
 #endif
 }
 
 void *Com_Allocate( int bytes ) {
-  return( malloc( bytes ) );
+       return( malloc( bytes ) );
 }
 
 void Com_Dealloc( void *ptr ) {
-  free( ptr );
+       free( ptr );
 }
 
 //
@@ -168,76 +162,76 @@ void Com_Dealloc( void *ptr ) {
 #endif
 
 int FS_Read( void *buffer, int len, fileHandle_t f ) {
-  return fread( buffer, len, 1, (FILE *)f );
+       return fread( buffer, len, 1, (FILE *)f );
 }
 
 int FS_Write( const void *buffer, int len, fileHandle_t h ) {
-  return fwrite( buffer, len, 1, (FILE *)h );
+       return fwrite( buffer, len, 1, (FILE *)h );
 }
 
 int FS_ReadFile( const char *qpath, void **buffer ) {
-  fileHandle_t h;
-  byte*                        buf;
-  int                          len;
+       fileHandle_t h;
+       byte*         buf;
+       int len;
 
-  buf = NULL;
+       buf = NULL;
 
-  len = FS_FOpenFileRead( qpath, &h, qfalse );
+       len = FS_FOpenFileRead( qpath, &h, qfalse );
 
-  if( h == 0 ) {
-    if ( buffer ) {
-      *buffer = NULL;
-    }
+       if ( h == 0 ) {
+               if ( buffer ) {
+                       *buffer = NULL;
+               }
 
-    return -1;
-  }
+               return -1;
+       }
 
-  buf = (byte *)Com_Allocate( len + 1 );
+       buf = (byte *)Com_Allocate( len + 1 );
 
-  *buffer = buf;
+       *buffer = buf;
 
-  FS_Read (buf, len, h);
+       FS_Read( buf, len, h );
 
-  buf[len] = 0;
-  FS_FCloseFile( h );
+       buf[len] = 0;
+       FS_FCloseFile( h );
 
-  return len;
+       return len;
 }
 
 void FS_FreeFile( void *buffer ) {
-  Com_Dealloc( buffer );
+       Com_Dealloc( buffer );
 }
 
 int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueFILE ) {
-  FILE *fh;
+       FILE  *fh;
        long len;
 
-  fh = fopen( filename, "rb" );
-  *file = *(fileHandle_t *)&fh;
+       fh = fopen( filename, "rb" );
+       *file = *(fileHandle_t *)&fh;
 
-  if( file )
-       {
-               fseek (fh, 0, SEEK_END);
-               len = ftell (fh);
-               rewind (fh);            
-    return len;
+       if ( file ) {
+               fseek( fh, 0, SEEK_END );
+               len = ftell( fh );
+               rewind( fh );
+               return len;
+       }
+       else{
+               return -1;
        }
-  else
-    return -1;
 }
 
 fileHandle_t FS_FOpenFileWrite( const char *filename ) {
-  FILE          *fh;
-  fileHandle_t  f;
+       FILE          *fh;
+       fileHandle_t f;
 
-  memset( &f, 0, sizeof(f) );
+       memset( &f, 0, sizeof( f ) );
 
-  fh = fopen( filename, "wb" );
+       fh = fopen( filename, "wb" );
 
-  f = (fileHandle_t)fh;
-  return f;
+       f = (fileHandle_t)fh;
+       return f;
 }
 
 void FS_FCloseFile( fileHandle_t f ) {
-  fclose( (FILE *)f );
+       fclose( (FILE *)f );
 }