+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-#ifndef _THREADS_H
-
-#define _THREADS_H
-
-
-extern int numthreads;
-
-void ThreadSetDefault( void );
-int GetThreadWork( void );
-void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )( int ) );
-void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) );
-void ThreadLock( void );
-void ThreadUnlock( void );
-
-#endif //_THREADS_H
--- /dev/null
+../../shared/common/qthreads.h
\ No newline at end of file
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-
-#ifndef __INOUT__
-#define __INOUT__
-
-#include "globaldefs.h"
-// inout is the only stuff relying on xml, include the headers there
-#include "libxml/tree.h"
-#include "mathlib.h"
-
-// some useful xml routines
-xmlNodePtr xml_NodeForVec( vec3_t v );
-void xml_SendNode( xmlNodePtr node );
-// print a message in q3map output and send the corresponding select information down the xml stream
-// bError: do we end with an error on this one or do we go ahead?
-void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError );
-// end q3map with an error message and send a point information in the xml stream
-// note: we might want to add a boolean to use this as a warning or an error thing..
-void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die );
-void xml_Point( char *msg, vec3_t pt );
-
-extern qboolean bNetworkBroadcast;
-void Broadcast_Setup( const char *dest );
-void Broadcast_Shutdown();
-
-#define SYS_VRB 0 // verbose support (on/off)
-#define SYS_STD 1 // standard print level
-#define SYS_WRN 2 // warnings
-#define SYS_ERR 3 // error
-#define SYS_NOXML 4 // don't send that down the XML stream
-
-extern qboolean verbose;
-void Sys_Printf( const char *text, ... );
-void Sys_FPrintf( int flag, const char *text, ... );
-void Error( const char *error, ... );
-
-#if GDEF_DEBUG
-#define DBG_XML 1
-#endif
-
-#ifdef DBG_XML
-void DumpXML();
-#endif
-
-#endif
--- /dev/null
+../../shared/common/inout.h
\ No newline at end of file
+++ /dev/null
-/*
- mdfour.c
-
- An implementation of MD4 designed for use in the samba SMB
- authentication protocol
-
- Copyright (C) 1997-1998 Andrew Tridgell
-
- This program 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.
-
- This program 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 this program; if not, write to:
-
- Free Software Foundation, Inc.
- 59 Temple Place - Suite 330
- Boston, MA 02111-1307, USA
-
- $Id: mdfour.c 7689 2007-11-12 14:28:40Z divverent $
- */
-
-#include <string.h> /* XoXus: needed for memset call */
-#include "md4.h"
-
-/* NOTE: This code makes no attempt to be fast!
-
- It assumes that a int is at least 32 bits long
- */
-
-static struct mdfour *m;
-
-#define F( X,Y,Z ) ( ( (X)&( Y ) ) | ( ( ~( X ) ) & ( Z ) ) )
-#define G( X,Y,Z ) ( ( (X)&( Y ) ) | ( (X)&( Z ) ) | ( (Y)&( Z ) ) )
-#define H( X,Y,Z ) ( ( X ) ^ ( Y ) ^ ( Z ) )
-#ifdef LARGE_INT32
-#define lshift( x,s ) ( ( ( ( x ) << ( s ) ) & 0xFFFFFFFF ) | ( ( ( x ) >> ( 32 - ( s ) ) ) & 0xFFFFFFFF ) )
-#else
-#define lshift( x,s ) ( ( ( x ) << ( s ) ) | ( ( x ) >> ( 32 - ( s ) ) ) )
-#endif
-
-#define ROUND1( a,b,c,d,k,s ) a = lshift( a + F( b,c,d ) + X[k], s )
-#define ROUND2( a,b,c,d,k,s ) a = lshift( a + G( b,c,d ) + X[k] + 0x5A827999,s )
-#define ROUND3( a,b,c,d,k,s ) a = lshift( a + H( b,c,d ) + X[k] + 0x6ED9EBA1,s )
-
-/* this applies md4 to 64 byte chunks */
-static void mdfour64( uint32 *M ){
- int j;
- uint32 AA, BB, CC, DD;
- uint32 X[16];
- uint32 A,B,C,D;
-
- for ( j = 0; j < 16; j++ )
- X[j] = M[j];
-
- A = m->A; B = m->B; C = m->C; D = m->D;
- AA = A; BB = B; CC = C; DD = D;
-
- ROUND1( A,B,C,D, 0, 3 ); ROUND1( D,A,B,C, 1, 7 );
- ROUND1( C,D,A,B, 2, 11 ); ROUND1( B,C,D,A, 3, 19 );
- ROUND1( A,B,C,D, 4, 3 ); ROUND1( D,A,B,C, 5, 7 );
- ROUND1( C,D,A,B, 6, 11 ); ROUND1( B,C,D,A, 7, 19 );
- ROUND1( A,B,C,D, 8, 3 ); ROUND1( D,A,B,C, 9, 7 );
- ROUND1( C,D,A,B, 10, 11 ); ROUND1( B,C,D,A, 11, 19 );
- ROUND1( A,B,C,D, 12, 3 ); ROUND1( D,A,B,C, 13, 7 );
- ROUND1( C,D,A,B, 14, 11 ); ROUND1( B,C,D,A, 15, 19 );
-
- ROUND2( A,B,C,D, 0, 3 ); ROUND2( D,A,B,C, 4, 5 );
- ROUND2( C,D,A,B, 8, 9 ); ROUND2( B,C,D,A, 12, 13 );
- ROUND2( A,B,C,D, 1, 3 ); ROUND2( D,A,B,C, 5, 5 );
- ROUND2( C,D,A,B, 9, 9 ); ROUND2( B,C,D,A, 13, 13 );
- ROUND2( A,B,C,D, 2, 3 ); ROUND2( D,A,B,C, 6, 5 );
- ROUND2( C,D,A,B, 10, 9 ); ROUND2( B,C,D,A, 14, 13 );
- ROUND2( A,B,C,D, 3, 3 ); ROUND2( D,A,B,C, 7, 5 );
- ROUND2( C,D,A,B, 11, 9 ); ROUND2( B,C,D,A, 15, 13 );
-
- ROUND3( A,B,C,D, 0, 3 ); ROUND3( D,A,B,C, 8, 9 );
- ROUND3( C,D,A,B, 4, 11 ); ROUND3( B,C,D,A, 12, 15 );
- ROUND3( A,B,C,D, 2, 3 ); ROUND3( D,A,B,C, 10, 9 );
- ROUND3( C,D,A,B, 6, 11 ); ROUND3( B,C,D,A, 14, 15 );
- ROUND3( A,B,C,D, 1, 3 ); ROUND3( D,A,B,C, 9, 9 );
- ROUND3( C,D,A,B, 5, 11 ); ROUND3( B,C,D,A, 13, 15 );
- ROUND3( A,B,C,D, 3, 3 ); ROUND3( D,A,B,C, 11, 9 );
- ROUND3( C,D,A,B, 7, 11 ); ROUND3( B,C,D,A, 15, 15 );
-
- A += AA; B += BB; C += CC; D += DD;
-
-#ifdef LARGE_INT32
- A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
- C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
-#endif
-
- for ( j = 0; j < 16; j++ )
- X[j] = 0;
-
- m->A = A; m->B = B; m->C = C; m->D = D;
-}
-
-static void copy64( uint32 *M, unsigned char *in ){
- int i;
-
- for ( i = 0; i < 16; i++ )
- M[i] = ( in[i * 4 + 3] << 24 ) | ( in[i * 4 + 2] << 16 ) |
- ( in[i * 4 + 1] << 8 ) | ( in[i * 4 + 0] << 0 );
-}
-
-static void copy4( unsigned char *out,uint32 x ){
- out[0] = x & 0xFF;
- out[1] = ( x >> 8 ) & 0xFF;
- out[2] = ( x >> 16 ) & 0xFF;
- out[3] = ( x >> 24 ) & 0xFF;
-}
-
-void mdfour_begin( struct mdfour *md ){
- md->A = 0x67452301;
- md->B = 0xefcdab89;
- md->C = 0x98badcfe;
- md->D = 0x10325476;
- md->totalN = 0;
-}
-
-
-static void mdfour_tail( unsigned char *in, int n ){
- unsigned char buf[128];
- uint32 M[16];
- uint32 b;
-
- m->totalN += n;
-
- b = m->totalN * 8;
-
- memset( buf, 0, 128 );
- if ( n ) {
- memcpy( buf, in, n );
- }
- buf[n] = 0x80;
-
- if ( n <= 55 ) {
- copy4( buf + 56, b );
- copy64( M, buf );
- mdfour64( M );
- }
- else {
- copy4( buf + 120, b );
- copy64( M, buf );
- mdfour64( M );
- copy64( M, buf + 64 );
- mdfour64( M );
- }
-}
-
-void mdfour_update( struct mdfour *md, unsigned char *in, int n ){
- uint32 M[16];
-
-// start of edit by Forest 'LordHavoc' Hale
-// commented out to prevent crashing when length is 0
-// if (n == 0) mdfour_tail(in, n);
-// end of edit by Forest 'LordHavoc' Hale
-
- m = md;
-
- while ( n >= 64 ) {
- copy64( M, in );
- mdfour64( M );
- in += 64;
- n -= 64;
- m->totalN += 64;
- }
-
- mdfour_tail( in, n );
-}
-
-
-void mdfour_result( struct mdfour *md, unsigned char *out ){
- m = md;
-
- copy4( out, m->A );
- copy4( out + 4, m->B );
- copy4( out + 8, m->C );
- copy4( out + 12, m->D );
-}
-
-
-void mdfour( unsigned char *out, unsigned char *in, int n ){
- struct mdfour md;
- mdfour_begin( &md );
- mdfour_update( &md, in, n );
- mdfour_result( &md, out );
-}
-
-///////////////////////////////////////////////////////////////
-// MD4-based checksum utility functions
-//
-// Copyright (C) 2000 Jeff Teunissen <d2deek@pmail.net>
-//
-// Author: Jeff Teunissen <d2deek@pmail.net>
-// Date: 01 Jan 2000
-
-unsigned Com_BlockChecksum( void *buffer, int length ){
- int digest[4];
- unsigned val;
-
- mdfour( (unsigned char *) digest, (unsigned char *) buffer, length );
-
- val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];
-
- return val;
-}
-
-void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf ){
- mdfour( outbuf, (unsigned char *) buffer, len );
-}
--- /dev/null
+../../shared/common/md4.c
\ No newline at end of file
+++ /dev/null
-/*
- mdfour.h
-
- an implementation of MD4 designed for use in the SMB authentication
- protocol
-
- Copyright (C) Andrew Tridgell 1997-1998
-
- This program 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.
-
- This program 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 this program; if not, write to:
-
- Free Software Foundation, Inc.
- 59 Temple Place - Suite 330
- Boston, MA 02111-1307, USA
- */
-
-#ifndef _MDFOUR_H
-#define _MDFOUR_H
-
-#ifndef int32
-#define int32 int
-#endif
-
-#if SIZEOF_INT > 4
-#define LARGE_INT32
-#endif
-
-#ifndef uint32
-#define uint32 unsigned int32
-#endif
-
-struct mdfour {
- uint32 A, B, C, D;
- uint32 totalN;
-};
-
-void mdfour_begin( struct mdfour *md ); // old: MD4Init
-void mdfour_update( struct mdfour *md, unsigned char *in, int n ); //old: MD4Update
-void mdfour_result( struct mdfour *md, unsigned char *out ); // old: MD4Final
-void mdfour( unsigned char *out, unsigned char *in, int n );
-
-unsigned Com_BlockChecksum( void *buffer, int length );
-void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf );
-
-#endif // _MDFOUR_H
--- /dev/null
+../../shared/common/md4.h
\ No newline at end of file
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-
-#ifndef __INOUT__
-#define __INOUT__
-
-#include "globaldefs.h"
-// inout is the only stuff relying on xml, include the headers there
-#include "libxml/tree.h"
-#include "mathlib.h"
-
-// some useful xml routines
-xmlNodePtr xml_NodeForVec( vec3_t v );
-void xml_SendNode( xmlNodePtr node );
-// print a message in q3map output and send the corresponding select information down the xml stream
-// bError: do we end with an error on this one or do we go ahead?
-void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError );
-// end q3map with an error message and send a point information in the xml stream
-// note: we might want to add a boolean to use this as a warning or an error thing..
-void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die );
-void xml_Point( char *msg, vec3_t pt );
-
-extern qboolean bNetworkBroadcast;
-void Broadcast_Setup( const char *dest );
-void Broadcast_Shutdown();
-
-#define SYS_VRB 0 // verbose support (on/off)
-#define SYS_STD 1 // standard print level
-#define SYS_WRN 2 // warnings
-#define SYS_ERR 3 // error
-#define SYS_NOXML 4 // don't send that down the XML stream
-
-extern qboolean verbose;
-void Sys_Printf( const char *text, ... );
-void Sys_FPrintf( int flag, const char *text, ... );
-void Error( const char *error, ... );
-
-#if GDEF_DEBUG
-#define DBG_XML 1
-#endif
-
-#ifdef DBG_XML
-void DumpXML();
-#endif
-
-#endif
--- /dev/null
+../../shared/common/inout.h
\ No newline at end of file
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-//
-// l3dslib.c: library for loading triangles from an Alias triangle file
-//
-
-#include <stdio.h>
-#include "cmdlib.h"
-#include "inout.h"
-#include "mathlib.h"
-#include "trilib.h"
-#include "l3dslib.h"
-
-#define MAIN3DS 0x4D4D
-#define EDIT3DS 0x3D3D // this is the start of the editor config
-#define EDIT_OBJECT 0x4000
-#define OBJ_TRIMESH 0x4100
-#define TRI_VERTEXL 0x4110
-#define TRI_FACEL1 0x4120
-
-#define MAXVERTS 2000
-
-typedef struct {
- int v[4];
-} tri;
-
-float fverts[MAXVERTS][3];
-tri tris[MAXTRIANGLES];
-
-int bytesread, level, numtris, totaltris;
-int vertsfound, trisfound;
-
-triangle_t *ptri;
-
-
-// Alias stores triangles as 3 explicit vertices in .tri files, so even though we
-// start out with a vertex pool and vertex indices for triangles, we have to convert
-// to raw, explicit triangles
-void StoreAliasTriangles( void ){
- int i, j, k;
-
- if ( ( totaltris + numtris ) > MAXTRIANGLES ) {
- Error( "Error: Too many triangles" );
- }
-
- for ( i = 0; i < numtris ; i++ )
- {
- for ( j = 0 ; j < 3 ; j++ )
- {
- for ( k = 0 ; k < 3 ; k++ )
- {
- ptri[i + totaltris].verts[j][k] = fverts[tris[i].v[j]][k];
- }
- }
- }
-
- totaltris += numtris;
- numtris = 0;
- vertsfound = 0;
- trisfound = 0;
-}
-
-
-int ParseVertexL( FILE *input ){
- int i, j, startbytesread, numverts;
- unsigned short tshort;
-
- if ( vertsfound ) {
- Error( "Error: Multiple vertex chunks" );
- }
-
- vertsfound = 1;
- startbytesread = bytesread;
-
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &tshort, sizeof( tshort ), 1, input );
- bytesread += sizeof( tshort );
- numverts = (int)tshort;
-
- if ( numverts > MAXVERTS ) {
- Error( "Error: Too many vertices" );
- }
-
- for ( i = 0 ; i < numverts ; i++ )
- {
- for ( j = 0 ; j < 3 ; j++ )
- {
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &fverts[i][j], sizeof( float ), 1, input );
- bytesread += sizeof( float );
- }
- }
-
- if ( vertsfound && trisfound ) {
- StoreAliasTriangles();
- }
-
- return bytesread - startbytesread;
-}
-
-
-int ParseFaceL1( FILE *input ){
-
- int i, j, startbytesread;
- unsigned short tshort;
-
- if ( trisfound ) {
- Error( "Error: Multiple face chunks" );
- }
-
- trisfound = 1;
- startbytesread = bytesread;
-
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &tshort, sizeof( tshort ), 1, input );
- bytesread += sizeof( tshort );
- numtris = (int)tshort;
-
- if ( numtris > MAXTRIANGLES ) {
- Error( "Error: Too many triangles" );
- }
-
- for ( i = 0 ; i < numtris ; i++ )
- {
- for ( j = 0 ; j < 4 ; j++ )
- {
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &tshort, sizeof( tshort ), 1, input );
- bytesread += sizeof( tshort );
- tris[i].v[j] = (int)tshort;
- }
- }
-
- if ( vertsfound && trisfound ) {
- StoreAliasTriangles();
- }
-
- return bytesread - startbytesread;
-}
-
-
-int ParseChunk( FILE *input ){
-#define BLOCK_SIZE 4096
- char temp[BLOCK_SIZE];
- unsigned short type;
- int i, length, w, t, retval;
-
- level++;
- retval = 0;
-
-// chunk type
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &type, sizeof( type ), 1, input );
- bytesread += sizeof( type );
-
-// chunk length
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &length, sizeof( length ), 1, input );
- bytesread += sizeof( length );
- w = length - 6;
-
-// process chunk if we care about it, otherwise skip it
- switch ( type )
- {
- case TRI_VERTEXL:
- w -= ParseVertexL( input );
- goto ParseSubchunk;
-
- case TRI_FACEL1:
- w -= ParseFaceL1( input );
- goto ParseSubchunk;
-
- case EDIT_OBJECT:
- // read the name
- i = 0;
-
- do
- {
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &temp[i], 1, 1, input );
- i++;
- w--;
- bytesread++;
- } while ( temp[i - 1] );
-
- case MAIN3DS:
- case OBJ_TRIMESH:
- case EDIT3DS:
- // parse through subchunks
-ParseSubchunk:
- while ( w > 0 )
- {
- w -= ParseChunk( input );
- }
-
- retval = length;
- goto Done;
-
- default:
- // skip other chunks
- while ( w > 0 )
- {
- t = w;
-
- if ( t > BLOCK_SIZE ) {
- t = BLOCK_SIZE;
- }
-
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &temp, t, 1, input );
- bytesread += t;
-
- w -= t;
- }
-
- retval = length;
- goto Done;
- }
-
-Done:
- level--;
- return retval;
-}
-
-
-void Load3DSTriangleList( char *filename, triangle_t **pptri, int *numtriangles ){
- FILE *input;
- short int tshort;
-
- bytesread = 0;
- level = 0;
- numtris = 0;
- totaltris = 0;
- vertsfound = 0;
- trisfound = 0;
-
- if ( ( input = fopen( filename, "rb" ) ) == 0 ) {
- fprintf( stderr,"reader: could not open file '%s'\n", filename );
- exit( 0 );
- }
-
- fread( &tshort, sizeof( tshort ), 1, input );
-
-// should only be MAIN3DS, but some files seem to start with EDIT3DS, with
-// no MAIN3DS
- if ( ( tshort != MAIN3DS ) && ( tshort != EDIT3DS ) ) {
- fprintf( stderr,"File is not a 3DS file.\n" );
- exit( 0 );
- }
-
-// back to top of file so we can parse the first chunk descriptor
- fseek( input, 0, SEEK_SET );
-
- ptri = malloc( MAXTRIANGLES * sizeof( triangle_t ) );
-
- *pptri = ptri;
-
-// parse through looking for the relevant chunk tree (MAIN3DS | EDIT3DS | EDIT_OBJECT |
-// OBJ_TRIMESH | {TRI_VERTEXL, TRI_FACEL1}) and skipping other chunks
- ParseChunk( input );
-
- if ( vertsfound || trisfound ) {
- Error( "Incomplete triangle set" );
- }
-
- *numtriangles = totaltris;
-
- fclose( input );
-}
--- /dev/null
+../../shared/common/l3dslib.c
\ No newline at end of file
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-//
-// l3dslib.h: header file for loading triangles from a 3DS triangle file
-//
-void Load3DSTriangleList( char *filename, triangle_t **pptri, int *numtriangles );
--- /dev/null
+../../shared/common/l3dslib.h
\ No newline at end of file
+++ /dev/null
-/*
- mdfour.c
-
- An implementation of MD4 designed for use in the samba SMB
- authentication protocol
-
- Copyright (C) 1997-1998 Andrew Tridgell
-
- This program 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.
-
- This program 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 this program; if not, write to:
-
- Free Software Foundation, Inc.
- 59 Temple Place - Suite 330
- Boston, MA 02111-1307, USA
-
- $Id: mdfour.c 7689 2007-11-12 14:28:40Z divverent $
- */
-
-#include <string.h> /* XoXus: needed for memset call */
-#include "md4.h"
-
-/* NOTE: This code makes no attempt to be fast!
-
- It assumes that a int is at least 32 bits long
- */
-
-static struct mdfour *m;
-
-#define F( X,Y,Z ) ( ( (X)&( Y ) ) | ( ( ~( X ) ) & ( Z ) ) )
-#define G( X,Y,Z ) ( ( (X)&( Y ) ) | ( (X)&( Z ) ) | ( (Y)&( Z ) ) )
-#define H( X,Y,Z ) ( ( X ) ^ ( Y ) ^ ( Z ) )
-#ifdef LARGE_INT32
-#define lshift( x,s ) ( ( ( ( x ) << ( s ) ) & 0xFFFFFFFF ) | ( ( ( x ) >> ( 32 - ( s ) ) ) & 0xFFFFFFFF ) )
-#else
-#define lshift( x,s ) ( ( ( x ) << ( s ) ) | ( ( x ) >> ( 32 - ( s ) ) ) )
-#endif
-
-#define ROUND1( a,b,c,d,k,s ) a = lshift( a + F( b,c,d ) + X[k], s )
-#define ROUND2( a,b,c,d,k,s ) a = lshift( a + G( b,c,d ) + X[k] + 0x5A827999,s )
-#define ROUND3( a,b,c,d,k,s ) a = lshift( a + H( b,c,d ) + X[k] + 0x6ED9EBA1,s )
-
-/* this applies md4 to 64 byte chunks */
-static void mdfour64( uint32 *M ){
- int j;
- uint32 AA, BB, CC, DD;
- uint32 X[16];
- uint32 A,B,C,D;
-
- for ( j = 0; j < 16; j++ )
- X[j] = M[j];
-
- A = m->A; B = m->B; C = m->C; D = m->D;
- AA = A; BB = B; CC = C; DD = D;
-
- ROUND1( A,B,C,D, 0, 3 ); ROUND1( D,A,B,C, 1, 7 );
- ROUND1( C,D,A,B, 2, 11 ); ROUND1( B,C,D,A, 3, 19 );
- ROUND1( A,B,C,D, 4, 3 ); ROUND1( D,A,B,C, 5, 7 );
- ROUND1( C,D,A,B, 6, 11 ); ROUND1( B,C,D,A, 7, 19 );
- ROUND1( A,B,C,D, 8, 3 ); ROUND1( D,A,B,C, 9, 7 );
- ROUND1( C,D,A,B, 10, 11 ); ROUND1( B,C,D,A, 11, 19 );
- ROUND1( A,B,C,D, 12, 3 ); ROUND1( D,A,B,C, 13, 7 );
- ROUND1( C,D,A,B, 14, 11 ); ROUND1( B,C,D,A, 15, 19 );
-
- ROUND2( A,B,C,D, 0, 3 ); ROUND2( D,A,B,C, 4, 5 );
- ROUND2( C,D,A,B, 8, 9 ); ROUND2( B,C,D,A, 12, 13 );
- ROUND2( A,B,C,D, 1, 3 ); ROUND2( D,A,B,C, 5, 5 );
- ROUND2( C,D,A,B, 9, 9 ); ROUND2( B,C,D,A, 13, 13 );
- ROUND2( A,B,C,D, 2, 3 ); ROUND2( D,A,B,C, 6, 5 );
- ROUND2( C,D,A,B, 10, 9 ); ROUND2( B,C,D,A, 14, 13 );
- ROUND2( A,B,C,D, 3, 3 ); ROUND2( D,A,B,C, 7, 5 );
- ROUND2( C,D,A,B, 11, 9 ); ROUND2( B,C,D,A, 15, 13 );
-
- ROUND3( A,B,C,D, 0, 3 ); ROUND3( D,A,B,C, 8, 9 );
- ROUND3( C,D,A,B, 4, 11 ); ROUND3( B,C,D,A, 12, 15 );
- ROUND3( A,B,C,D, 2, 3 ); ROUND3( D,A,B,C, 10, 9 );
- ROUND3( C,D,A,B, 6, 11 ); ROUND3( B,C,D,A, 14, 15 );
- ROUND3( A,B,C,D, 1, 3 ); ROUND3( D,A,B,C, 9, 9 );
- ROUND3( C,D,A,B, 5, 11 ); ROUND3( B,C,D,A, 13, 15 );
- ROUND3( A,B,C,D, 3, 3 ); ROUND3( D,A,B,C, 11, 9 );
- ROUND3( C,D,A,B, 7, 11 ); ROUND3( B,C,D,A, 15, 15 );
-
- A += AA; B += BB; C += CC; D += DD;
-
-#ifdef LARGE_INT32
- A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
- C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
-#endif
-
- for ( j = 0; j < 16; j++ )
- X[j] = 0;
-
- m->A = A; m->B = B; m->C = C; m->D = D;
-}
-
-static void copy64( uint32 *M, unsigned char *in ){
- int i;
-
- for ( i = 0; i < 16; i++ )
- M[i] = ( in[i * 4 + 3] << 24 ) | ( in[i * 4 + 2] << 16 ) |
- ( in[i * 4 + 1] << 8 ) | ( in[i * 4 + 0] << 0 );
-}
-
-static void copy4( unsigned char *out,uint32 x ){
- out[0] = x & 0xFF;
- out[1] = ( x >> 8 ) & 0xFF;
- out[2] = ( x >> 16 ) & 0xFF;
- out[3] = ( x >> 24 ) & 0xFF;
-}
-
-void mdfour_begin( struct mdfour *md ){
- md->A = 0x67452301;
- md->B = 0xefcdab89;
- md->C = 0x98badcfe;
- md->D = 0x10325476;
- md->totalN = 0;
-}
-
-
-static void mdfour_tail( unsigned char *in, int n ){
- unsigned char buf[128];
- uint32 M[16];
- uint32 b;
-
- m->totalN += n;
-
- b = m->totalN * 8;
-
- memset( buf, 0, 128 );
- if ( n ) {
- memcpy( buf, in, n );
- }
- buf[n] = 0x80;
-
- if ( n <= 55 ) {
- copy4( buf + 56, b );
- copy64( M, buf );
- mdfour64( M );
- }
- else {
- copy4( buf + 120, b );
- copy64( M, buf );
- mdfour64( M );
- copy64( M, buf + 64 );
- mdfour64( M );
- }
-}
-
-void mdfour_update( struct mdfour *md, unsigned char *in, int n ){
- uint32 M[16];
-
-// start of edit by Forest 'LordHavoc' Hale
-// commented out to prevent crashing when length is 0
-// if (n == 0) mdfour_tail(in, n);
-// end of edit by Forest 'LordHavoc' Hale
-
- m = md;
-
- while ( n >= 64 ) {
- copy64( M, in );
- mdfour64( M );
- in += 64;
- n -= 64;
- m->totalN += 64;
- }
-
- mdfour_tail( in, n );
-}
-
-
-void mdfour_result( struct mdfour *md, unsigned char *out ){
- m = md;
-
- copy4( out, m->A );
- copy4( out + 4, m->B );
- copy4( out + 8, m->C );
- copy4( out + 12, m->D );
-}
-
-
-void mdfour( unsigned char *out, unsigned char *in, int n ){
- struct mdfour md;
- mdfour_begin( &md );
- mdfour_update( &md, in, n );
- mdfour_result( &md, out );
-}
-
-///////////////////////////////////////////////////////////////
-// MD4-based checksum utility functions
-//
-// Copyright (C) 2000 Jeff Teunissen <d2deek@pmail.net>
-//
-// Author: Jeff Teunissen <d2deek@pmail.net>
-// Date: 01 Jan 2000
-
-unsigned Com_BlockChecksum( void *buffer, int length ){
- int digest[4];
- unsigned val;
-
- mdfour( (unsigned char *) digest, (unsigned char *) buffer, length );
-
- val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];
-
- return val;
-}
-
-void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf ){
- mdfour( outbuf, (unsigned char *) buffer, len );
-}
--- /dev/null
+../../shared/common/md4.c
\ No newline at end of file
+++ /dev/null
-/*
- mdfour.h
-
- an implementation of MD4 designed for use in the SMB authentication
- protocol
-
- Copyright (C) Andrew Tridgell 1997-1998
-
- This program 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.
-
- This program 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 this program; if not, write to:
-
- Free Software Foundation, Inc.
- 59 Temple Place - Suite 330
- Boston, MA 02111-1307, USA
- */
-
-#ifndef _MDFOUR_H
-#define _MDFOUR_H
-
-#ifndef int32
-#define int32 int
-#endif
-
-#if SIZEOF_INT > 4
-#define LARGE_INT32
-#endif
-
-#ifndef uint32
-#define uint32 unsigned int32
-#endif
-
-struct mdfour {
- uint32 A, B, C, D;
- uint32 totalN;
-};
-
-void mdfour_begin( struct mdfour *md ); // old: MD4Init
-void mdfour_update( struct mdfour *md, unsigned char *in, int n ); //old: MD4Update
-void mdfour_result( struct mdfour *md, unsigned char *out ); // old: MD4Final
-void mdfour( unsigned char *out, unsigned char *in, int n );
-
-unsigned Com_BlockChecksum( void *buffer, int length );
-void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf );
-
-#endif // _MDFOUR_H
--- /dev/null
+../../shared/common/md4.h
\ No newline at end of file
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-#ifndef _THREADS_H
-
-#define _THREADS_H
-
-extern int numthreads;
-
-void ThreadSetDefault( void );
-int GetThreadWork( void );
-void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )( int ) );
-void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) );
-void ThreadLock( void );
-void ThreadUnlock( void );
-
-#endif // _THREADS_H
--- /dev/null
+../../shared/common/qthreads.h
\ No newline at end of file
double I_FloatTime( void );
-void Error( const char *error, ... ) GDEF_ATTRIBUTE_NORETURN;
int CheckParm( const char *check );
FILE *SafeOpenWrite( const char *filename );
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-
-#ifndef __INOUT__
-#define __INOUT__
-
-#include "globaldefs.h"
-// inout is the only stuff relying on xml, include the headers there
-#include "libxml/tree.h"
-#include "mathlib.h"
-
-// some useful xml routines
-xmlNodePtr xml_NodeForVec( vec3_t v );
-void xml_SendNode( xmlNodePtr node );
-// print a message in q3map output and send the corresponding select information down the xml stream
-// bError: do we end with an error on this one or do we go ahead?
-void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError );
-// end q3map with an error message and send a point information in the xml stream
-// note: we might want to add a boolean to use this as a warning or an error thing..
-void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die );
-void xml_Point( char *msg, vec3_t pt );
-
-extern qboolean bNetworkBroadcast;
-void Broadcast_Setup( const char *dest );
-void Broadcast_Shutdown();
-
-#define SYS_VRB 0 // verbose support (on/off)
-#define SYS_STD 1 // standard print level
-#define SYS_WRN 2 // warnings
-#define SYS_ERR 3 // error
-#define SYS_NOXML 4 // don't send that down the XML stream
-
-extern qboolean verbose;
-extern qboolean werror;
-void Sys_Printf( const char *text, ... );
-void Sys_FPrintf( int flag, const char *text, ... );
-
-#if GDEF_DEBUG
-#define DBG_XML 1
-#endif
-
-#ifdef DBG_XML
-void DumpXML();
-#endif
-
-#endif
--- /dev/null
+../../shared/common/inout.h
\ No newline at end of file
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-
-//
-// l3dslib.c: library for loading triangles from an Alias triangle file
-//
-
-#include <stdio.h>
-#include "cmdlib.h"
-#include "mathlib.h"
-#include "trilib.h"
-#include "l3dslib.h"
-
-#define MAIN3DS 0x4D4D
-#define EDIT3DS 0x3D3D // this is the start of the editor config
-#define EDIT_OBJECT 0x4000
-#define OBJ_TRIMESH 0x4100
-#define TRI_VERTEXL 0x4110
-#define TRI_FACEL1 0x4120
-
-#define MAXVERTS 2000
-#define MAXTRIANGLES 750
-
-typedef struct {
- int v[4];
-} tri;
-
-float fverts[MAXVERTS][3];
-tri tris[MAXTRIANGLES];
-
-int bytesread, level, numtris, totaltris;
-int vertsfound, trisfound;
-
-triangle_t *ptri;
-
-
-// Alias stores triangles as 3 explicit vertices in .tri files, so even though we
-// start out with a vertex pool and vertex indices for triangles, we have to convert
-// to raw, explicit triangles
-void StoreAliasTriangles( void ){
- int i, j, k;
-
- if ( ( totaltris + numtris ) > MAXTRIANGLES ) {
- Error( "Error: Too many triangles" );
- }
-
- for ( i = 0; i < numtris ; i++ )
- {
- for ( j = 0 ; j < 3 ; j++ )
- {
- for ( k = 0 ; k < 3 ; k++ )
- {
- ptri[i + totaltris].verts[j][k] = fverts[tris[i].v[j]][k];
- }
- }
- }
-
- totaltris += numtris;
- numtris = 0;
- vertsfound = 0;
- trisfound = 0;
-}
-
-
-int ParseVertexL( FILE *input ){
- int i, j, startbytesread, numverts;
- unsigned short tshort;
-
- if ( vertsfound ) {
- Error( "Error: Multiple vertex chunks" );
- }
-
- vertsfound = 1;
- startbytesread = bytesread;
-
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &tshort, sizeof( tshort ), 1, input );
- bytesread += sizeof( tshort );
- numverts = (int)tshort;
-
- if ( numverts > MAXVERTS ) {
- Error( "Error: Too many vertices" );
- }
-
- for ( i = 0 ; i < numverts ; i++ )
- {
- for ( j = 0 ; j < 3 ; j++ )
- {
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &fverts[i][j], sizeof( float ), 1, input );
- bytesread += sizeof( float );
- }
- }
-
- if ( vertsfound && trisfound ) {
- StoreAliasTriangles();
- }
-
- return bytesread - startbytesread;
-}
-
-
-int ParseFaceL1( FILE *input ){
-
- int i, j, startbytesread;
- unsigned short tshort;
-
- if ( trisfound ) {
- Error( "Error: Multiple face chunks" );
- }
-
- trisfound = 1;
- startbytesread = bytesread;
-
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &tshort, sizeof( tshort ), 1, input );
- bytesread += sizeof( tshort );
- numtris = (int)tshort;
-
- if ( numtris > MAXTRIANGLES ) {
- Error( "Error: Too many triangles" );
- }
-
- for ( i = 0 ; i < numtris ; i++ )
- {
- for ( j = 0 ; j < 4 ; j++ )
- {
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &tshort, sizeof( tshort ), 1, input );
- bytesread += sizeof( tshort );
- tris[i].v[j] = (int)tshort;
- }
- }
-
- if ( vertsfound && trisfound ) {
- StoreAliasTriangles();
- }
-
- return bytesread - startbytesread;
-}
-
-
-int ParseChunk( FILE *input ){
-#define BLOCK_SIZE 4096
- char temp[BLOCK_SIZE];
- unsigned short type;
- int i, length, w, t, retval;
-
- level++;
- retval = 0;
-
-// chunk type
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &type, sizeof( type ), 1, input );
- bytesread += sizeof( type );
-
-// chunk length
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &length, sizeof( length ), 1, input );
- bytesread += sizeof( length );
- w = length - 6;
-
-// process chunk if we care about it, otherwise skip it
- switch ( type )
- {
- case TRI_VERTEXL:
- w -= ParseVertexL( input );
- goto ParseSubchunk;
-
- case TRI_FACEL1:
- w -= ParseFaceL1( input );
- goto ParseSubchunk;
-
- case EDIT_OBJECT:
- // read the name
- i = 0;
-
- do
- {
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &temp[i], 1, 1, input );
- i++;
- w--;
- bytesread++;
- } while ( temp[i - 1] );
-
- case MAIN3DS:
- case OBJ_TRIMESH:
- case EDIT3DS:
- // parse through subchunks
-ParseSubchunk:
- while ( w > 0 )
- {
- w -= ParseChunk( input );
- }
-
- retval = length;
- goto Done;
-
- default:
- // skip other chunks
- while ( w > 0 )
- {
- t = w;
-
- if ( t > BLOCK_SIZE ) {
- t = BLOCK_SIZE;
- }
-
- if ( feof( input ) ) {
- Error( "Error: unexpected end of file" );
- }
-
- fread( &temp, t, 1, input );
- bytesread += t;
-
- w -= t;
- }
-
- retval = length;
- goto Done;
- }
-
-Done:
- level--;
- return retval;
-}
-
-
-void Load3DSTriangleList( char *filename, triangle_t **pptri, int *numtriangles ){
- FILE *input;
- short int tshort;
-
- bytesread = 0;
- level = 0;
- numtris = 0;
- totaltris = 0;
- vertsfound = 0;
- trisfound = 0;
-
- if ( ( input = fopen( filename, "rb" ) ) == 0 ) {
- fprintf( stderr,"reader: could not open file '%s'\n", filename );
- exit( 0 );
- }
-
- fread( &tshort, sizeof( tshort ), 1, input );
-
-// should only be MAIN3DS, but some files seem to start with EDIT3DS, with
-// no MAIN3DS
- if ( ( tshort != MAIN3DS ) && ( tshort != EDIT3DS ) ) {
- fprintf( stderr,"File is not a 3DS file.\n" );
- exit( 0 );
- }
-
-// back to top of file so we can parse the first chunk descriptor
- fseek( input, 0, SEEK_SET );
-
- ptri = safe_malloc( MAXTRIANGLES * sizeof( triangle_t ) );
-
- *pptri = ptri;
-
-// parse through looking for the relevant chunk tree (MAIN3DS | EDIT3DS | EDIT_OBJECT |
-// OBJ_TRIMESH | {TRI_VERTEXL, TRI_FACEL1}) and skipping other chunks
- ParseChunk( input );
-
- if ( vertsfound || trisfound ) {
- Error( "Incomplete triangle set" );
- }
-
- *numtriangles = totaltris;
-
- fclose( input );
-}
--- /dev/null
+../../shared/common/l3dslib.c
\ No newline at end of file
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-
-//
-// l3dslib.h: header file for loading triangles from a 3DS triangle file
-//
-void Load3DSTriangleList( char *filename, triangle_t **pptri, int *numtriangles );
--- /dev/null
+../../shared/common/l3dslib.h
\ No newline at end of file
+++ /dev/null
-/*
- mdfour.c
-
- An implementation of MD4 designed for use in the samba SMB
- authentication protocol
-
- Copyright (C) 1997-1998 Andrew Tridgell
-
- This program 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.
-
- This program 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 this program; if not, write to:
-
- Free Software Foundation, Inc.
- 59 Temple Place - Suite 330
- Boston, MA 02111-1307, USA
-
- $Id: mdfour.c 7689 2007-11-12 14:28:40Z divverent $
- */
-
-#include <string.h> /* XoXus: needed for memset call */
-#include "md4.h"
-
-/* NOTE: This code makes no attempt to be fast!
-
- It assumes that a int is at least 32 bits long
- */
-
-static struct mdfour *m;
-
-#define F( X,Y,Z ) ( ( (X)&( Y ) ) | ( ( ~( X ) ) & ( Z ) ) )
-#define G( X,Y,Z ) ( ( (X)&( Y ) ) | ( (X)&( Z ) ) | ( (Y)&( Z ) ) )
-#define H( X,Y,Z ) ( ( X ) ^ ( Y ) ^ ( Z ) )
-#ifdef LARGE_INT32
-#define lshift( x,s ) ( ( ( ( x ) << ( s ) ) & 0xFFFFFFFF ) | ( ( ( x ) >> ( 32 - ( s ) ) ) & 0xFFFFFFFF ) )
-#else
-#define lshift( x,s ) ( ( ( x ) << ( s ) ) | ( ( x ) >> ( 32 - ( s ) ) ) )
-#endif
-
-#define ROUND1( a,b,c,d,k,s ) a = lshift( a + F( b,c,d ) + X[k], s )
-#define ROUND2( a,b,c,d,k,s ) a = lshift( a + G( b,c,d ) + X[k] + 0x5A827999,s )
-#define ROUND3( a,b,c,d,k,s ) a = lshift( a + H( b,c,d ) + X[k] + 0x6ED9EBA1,s )
-
-/* this applies md4 to 64 byte chunks */
-static void mdfour64( uint32 *M ){
- int j;
- uint32 AA, BB, CC, DD;
- uint32 X[16];
- uint32 A,B,C,D;
-
- for ( j = 0; j < 16; j++ )
- X[j] = M[j];
-
- A = m->A; B = m->B; C = m->C; D = m->D;
- AA = A; BB = B; CC = C; DD = D;
-
- ROUND1( A,B,C,D, 0, 3 ); ROUND1( D,A,B,C, 1, 7 );
- ROUND1( C,D,A,B, 2, 11 ); ROUND1( B,C,D,A, 3, 19 );
- ROUND1( A,B,C,D, 4, 3 ); ROUND1( D,A,B,C, 5, 7 );
- ROUND1( C,D,A,B, 6, 11 ); ROUND1( B,C,D,A, 7, 19 );
- ROUND1( A,B,C,D, 8, 3 ); ROUND1( D,A,B,C, 9, 7 );
- ROUND1( C,D,A,B, 10, 11 ); ROUND1( B,C,D,A, 11, 19 );
- ROUND1( A,B,C,D, 12, 3 ); ROUND1( D,A,B,C, 13, 7 );
- ROUND1( C,D,A,B, 14, 11 ); ROUND1( B,C,D,A, 15, 19 );
-
- ROUND2( A,B,C,D, 0, 3 ); ROUND2( D,A,B,C, 4, 5 );
- ROUND2( C,D,A,B, 8, 9 ); ROUND2( B,C,D,A, 12, 13 );
- ROUND2( A,B,C,D, 1, 3 ); ROUND2( D,A,B,C, 5, 5 );
- ROUND2( C,D,A,B, 9, 9 ); ROUND2( B,C,D,A, 13, 13 );
- ROUND2( A,B,C,D, 2, 3 ); ROUND2( D,A,B,C, 6, 5 );
- ROUND2( C,D,A,B, 10, 9 ); ROUND2( B,C,D,A, 14, 13 );
- ROUND2( A,B,C,D, 3, 3 ); ROUND2( D,A,B,C, 7, 5 );
- ROUND2( C,D,A,B, 11, 9 ); ROUND2( B,C,D,A, 15, 13 );
-
- ROUND3( A,B,C,D, 0, 3 ); ROUND3( D,A,B,C, 8, 9 );
- ROUND3( C,D,A,B, 4, 11 ); ROUND3( B,C,D,A, 12, 15 );
- ROUND3( A,B,C,D, 2, 3 ); ROUND3( D,A,B,C, 10, 9 );
- ROUND3( C,D,A,B, 6, 11 ); ROUND3( B,C,D,A, 14, 15 );
- ROUND3( A,B,C,D, 1, 3 ); ROUND3( D,A,B,C, 9, 9 );
- ROUND3( C,D,A,B, 5, 11 ); ROUND3( B,C,D,A, 13, 15 );
- ROUND3( A,B,C,D, 3, 3 ); ROUND3( D,A,B,C, 11, 9 );
- ROUND3( C,D,A,B, 7, 11 ); ROUND3( B,C,D,A, 15, 15 );
-
- A += AA; B += BB; C += CC; D += DD;
-
-#ifdef LARGE_INT32
- A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
- C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
-#endif
-
- for ( j = 0; j < 16; j++ )
- X[j] = 0;
-
- m->A = A; m->B = B; m->C = C; m->D = D;
-}
-
-static void copy64( uint32 *M, unsigned char *in ){
- int i;
-
- for ( i = 0; i < 16; i++ )
- M[i] = ( in[i * 4 + 3] << 24 ) | ( in[i * 4 + 2] << 16 ) |
- ( in[i * 4 + 1] << 8 ) | ( in[i * 4 + 0] << 0 );
-}
-
-static void copy4( unsigned char *out,uint32 x ){
- out[0] = x & 0xFF;
- out[1] = ( x >> 8 ) & 0xFF;
- out[2] = ( x >> 16 ) & 0xFF;
- out[3] = ( x >> 24 ) & 0xFF;
-}
-
-void mdfour_begin( struct mdfour *md ){
- md->A = 0x67452301;
- md->B = 0xefcdab89;
- md->C = 0x98badcfe;
- md->D = 0x10325476;
- md->totalN = 0;
-}
-
-
-static void mdfour_tail( unsigned char *in, int n ){
- unsigned char buf[128];
- uint32 M[16];
- uint32 b;
-
- m->totalN += n;
-
- b = m->totalN * 8;
-
- memset( buf, 0, 128 );
- if ( n ) {
- memcpy( buf, in, n );
- }
- buf[n] = 0x80;
-
- if ( n <= 55 ) {
- copy4( buf + 56, b );
- copy64( M, buf );
- mdfour64( M );
- }
- else {
- copy4( buf + 120, b );
- copy64( M, buf );
- mdfour64( M );
- copy64( M, buf + 64 );
- mdfour64( M );
- }
-}
-
-void mdfour_update( struct mdfour *md, unsigned char *in, int n ){
- uint32 M[16];
-
-// start of edit by Forest 'LordHavoc' Hale
-// commented out to prevent crashing when length is 0
-// if (n == 0) mdfour_tail(in, n);
-// end of edit by Forest 'LordHavoc' Hale
-
- m = md;
-
- while ( n >= 64 ) {
- copy64( M, in );
- mdfour64( M );
- in += 64;
- n -= 64;
- m->totalN += 64;
- }
-
- mdfour_tail( in, n );
-}
-
-
-void mdfour_result( struct mdfour *md, unsigned char *out ){
- m = md;
-
- copy4( out, m->A );
- copy4( out + 4, m->B );
- copy4( out + 8, m->C );
- copy4( out + 12, m->D );
-}
-
-
-void mdfour( unsigned char *out, unsigned char *in, int n ){
- struct mdfour md;
- mdfour_begin( &md );
- mdfour_update( &md, in, n );
- mdfour_result( &md, out );
-}
-
-///////////////////////////////////////////////////////////////
-// MD4-based checksum utility functions
-//
-// Copyright (C) 2000 Jeff Teunissen <d2deek@pmail.net>
-//
-// Author: Jeff Teunissen <d2deek@pmail.net>
-// Date: 01 Jan 2000
-
-unsigned Com_BlockChecksum( void *buffer, int length ){
- int digest[4];
- unsigned val;
-
- mdfour( (unsigned char *) digest, (unsigned char *) buffer, length );
-
- val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];
-
- return val;
-}
-
-void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf ){
- mdfour( outbuf, (unsigned char *) buffer, len );
-}
--- /dev/null
+../../shared/common/md4.c
\ No newline at end of file
+++ /dev/null
-/*
- mdfour.h
-
- an implementation of MD4 designed for use in the SMB authentication
- protocol
-
- Copyright (C) Andrew Tridgell 1997-1998
-
- This program 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.
-
- This program 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 this program; if not, write to:
-
- Free Software Foundation, Inc.
- 59 Temple Place - Suite 330
- Boston, MA 02111-1307, USA
- */
-
-#ifndef _MDFOUR_H
-#define _MDFOUR_H
-
-#ifndef int32
-#define int32 int
-#endif
-
-#if SIZEOF_INT > 4
-#define LARGE_INT32
-#endif
-
-#ifndef uint32
-#define uint32 unsigned int32
-#endif
-
-struct mdfour {
- uint32 A, B, C, D;
- uint32 totalN;
-};
-
-void mdfour_begin( struct mdfour *md ); // old: MD4Init
-void mdfour_update( struct mdfour *md, unsigned char *in, int n ); //old: MD4Update
-void mdfour_result( struct mdfour *md, unsigned char *out ); // old: MD4Final
-void mdfour( unsigned char *out, unsigned char *in, int n );
-
-unsigned Com_BlockChecksum( void *buffer, int length );
-void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf );
-
-#endif // _MDFOUR_H
--- /dev/null
+../../shared/common/md4.h
\ No newline at end of file
+++ /dev/null
-/*
- 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.
-
- 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.
-
- 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
- */
-
-
-extern int numthreads;
-
-void ThreadSetDefault( void );
-int GetThreadWork( void );
-void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )( int ) );
-void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) );
-void ThreadLock( void );
-void ThreadUnlock( void );
--- /dev/null
+../../shared/common/qthreads.h
\ No newline at end of file
--- /dev/null
+/*
+ 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.
+
+ 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.
+
+ 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
+ */
+
+#ifndef __INOUT__
+#define __INOUT__
+
+#include "globaldefs.h"
+// inout is the only stuff relying on xml, include the headers there
+#include "libxml/tree.h"
+#include "mathlib.h"
+
+// some useful xml routines
+xmlNodePtr xml_NodeForVec( vec3_t v );
+void xml_SendNode( xmlNodePtr node );
+// print a message in q3map output and send the corresponding select information down the xml stream
+// bError: do we end with an error on this one or do we go ahead?
+void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError );
+// end q3map with an error message and send a point information in the xml stream
+// note: we might want to add a boolean to use this as a warning or an error thing..
+void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die );
+void xml_Point( char *msg, vec3_t pt );
+
+extern qboolean bNetworkBroadcast;
+void Broadcast_Setup( const char *dest );
+void Broadcast_Shutdown();
+
+#define SYS_VRB 0 // verbose support (on/off)
+#define SYS_STD 1 // standard print level
+#define SYS_WRN 2 // warnings
+#define SYS_ERR 3 // error
+#define SYS_NOXML 4 // don't send that down the XML stream
+
+extern qboolean verbose;
+extern qboolean werror;
+void Sys_Printf( const char *text, ... );
+void Sys_FPrintf( int flag, const char *text, ... );
+void Error( const char *error, ... ) GDEF_ATTRIBUTE_NORETURN;
+
+#if GDEF_DEBUG
+#define DBG_XML 1
+#endif
+
+#ifdef DBG_XML
+void DumpXML();
+#endif
+
+#endif
--- /dev/null
+/*
+ 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.
+
+ 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.
+
+ 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
+ */
+
+//
+// l3dslib.c: library for loading triangles from an Alias triangle file
+//
+
+#include <stdio.h>
+#include "cmdlib.h"
+#include "mathlib.h"
+#include "trilib.h"
+#include "l3dslib.h"
+
+#define MAIN3DS 0x4D4D
+#define EDIT3DS 0x3D3D // this is the start of the editor config
+#define EDIT_OBJECT 0x4000
+#define OBJ_TRIMESH 0x4100
+#define TRI_VERTEXL 0x4110
+#define TRI_FACEL1 0x4120
+
+#define MAXVERTS 2000
+#define MAXTRIANGLES 750
+
+typedef struct {
+ int v[4];
+} tri;
+
+float fverts[MAXVERTS][3];
+tri tris[MAXTRIANGLES];
+
+int bytesread, level, numtris, totaltris;
+int vertsfound, trisfound;
+
+triangle_t *ptri;
+
+
+// Alias stores triangles as 3 explicit vertices in .tri files, so even though we
+// start out with a vertex pool and vertex indices for triangles, we have to convert
+// to raw, explicit triangles
+void StoreAliasTriangles( void ){
+ int i, j, k;
+
+ if ( ( totaltris + numtris ) > MAXTRIANGLES ) {
+ Error( "Error: Too many triangles" );
+ }
+
+ for ( i = 0; i < numtris ; i++ )
+ {
+ for ( j = 0 ; j < 3 ; j++ )
+ {
+ for ( k = 0 ; k < 3 ; k++ )
+ {
+ ptri[i + totaltris].verts[j][k] = fverts[tris[i].v[j]][k];
+ }
+ }
+ }
+
+ totaltris += numtris;
+ numtris = 0;
+ vertsfound = 0;
+ trisfound = 0;
+}
+
+
+int ParseVertexL( FILE *input ){
+ int i, j, startbytesread, numverts;
+ unsigned short tshort;
+
+ if ( vertsfound ) {
+ Error( "Error: Multiple vertex chunks" );
+ }
+
+ vertsfound = 1;
+ startbytesread = bytesread;
+
+ if ( feof( input ) ) {
+ Error( "Error: unexpected end of file" );
+ }
+
+ fread( &tshort, sizeof( tshort ), 1, input );
+ bytesread += sizeof( tshort );
+ numverts = (int)tshort;
+
+ if ( numverts > MAXVERTS ) {
+ Error( "Error: Too many vertices" );
+ }
+
+ for ( i = 0 ; i < numverts ; i++ )
+ {
+ for ( j = 0 ; j < 3 ; j++ )
+ {
+ if ( feof( input ) ) {
+ Error( "Error: unexpected end of file" );
+ }
+
+ fread( &fverts[i][j], sizeof( float ), 1, input );
+ bytesread += sizeof( float );
+ }
+ }
+
+ if ( vertsfound && trisfound ) {
+ StoreAliasTriangles();
+ }
+
+ return bytesread - startbytesread;
+}
+
+
+int ParseFaceL1( FILE *input ){
+
+ int i, j, startbytesread;
+ unsigned short tshort;
+
+ if ( trisfound ) {
+ Error( "Error: Multiple face chunks" );
+ }
+
+ trisfound = 1;
+ startbytesread = bytesread;
+
+ if ( feof( input ) ) {
+ Error( "Error: unexpected end of file" );
+ }
+
+ fread( &tshort, sizeof( tshort ), 1, input );
+ bytesread += sizeof( tshort );
+ numtris = (int)tshort;
+
+ if ( numtris > MAXTRIANGLES ) {
+ Error( "Error: Too many triangles" );
+ }
+
+ for ( i = 0 ; i < numtris ; i++ )
+ {
+ for ( j = 0 ; j < 4 ; j++ )
+ {
+ if ( feof( input ) ) {
+ Error( "Error: unexpected end of file" );
+ }
+
+ fread( &tshort, sizeof( tshort ), 1, input );
+ bytesread += sizeof( tshort );
+ tris[i].v[j] = (int)tshort;
+ }
+ }
+
+ if ( vertsfound && trisfound ) {
+ StoreAliasTriangles();
+ }
+
+ return bytesread - startbytesread;
+}
+
+
+int ParseChunk( FILE *input ){
+#define BLOCK_SIZE 4096
+ char temp[BLOCK_SIZE];
+ unsigned short type;
+ int i, length, w, t, retval;
+
+ level++;
+ retval = 0;
+
+// chunk type
+ if ( feof( input ) ) {
+ Error( "Error: unexpected end of file" );
+ }
+
+ fread( &type, sizeof( type ), 1, input );
+ bytesread += sizeof( type );
+
+// chunk length
+ if ( feof( input ) ) {
+ Error( "Error: unexpected end of file" );
+ }
+
+ fread( &length, sizeof( length ), 1, input );
+ bytesread += sizeof( length );
+ w = length - 6;
+
+// process chunk if we care about it, otherwise skip it
+ switch ( type )
+ {
+ case TRI_VERTEXL:
+ w -= ParseVertexL( input );
+ goto ParseSubchunk;
+
+ case TRI_FACEL1:
+ w -= ParseFaceL1( input );
+ goto ParseSubchunk;
+
+ case EDIT_OBJECT:
+ // read the name
+ i = 0;
+
+ do
+ {
+ if ( feof( input ) ) {
+ Error( "Error: unexpected end of file" );
+ }
+
+ fread( &temp[i], 1, 1, input );
+ i++;
+ w--;
+ bytesread++;
+ } while ( temp[i - 1] );
+
+ case MAIN3DS:
+ case OBJ_TRIMESH:
+ case EDIT3DS:
+ // parse through subchunks
+ParseSubchunk:
+ while ( w > 0 )
+ {
+ w -= ParseChunk( input );
+ }
+
+ retval = length;
+ goto Done;
+
+ default:
+ // skip other chunks
+ while ( w > 0 )
+ {
+ t = w;
+
+ if ( t > BLOCK_SIZE ) {
+ t = BLOCK_SIZE;
+ }
+
+ if ( feof( input ) ) {
+ Error( "Error: unexpected end of file" );
+ }
+
+ fread( &temp, t, 1, input );
+ bytesread += t;
+
+ w -= t;
+ }
+
+ retval = length;
+ goto Done;
+ }
+
+Done:
+ level--;
+ return retval;
+}
+
+
+void Load3DSTriangleList( char *filename, triangle_t **pptri, int *numtriangles ){
+ FILE *input;
+ short int tshort;
+
+ bytesread = 0;
+ level = 0;
+ numtris = 0;
+ totaltris = 0;
+ vertsfound = 0;
+ trisfound = 0;
+
+ if ( ( input = fopen( filename, "rb" ) ) == 0 ) {
+ fprintf( stderr,"reader: could not open file '%s'\n", filename );
+ exit( 0 );
+ }
+
+ fread( &tshort, sizeof( tshort ), 1, input );
+
+// should only be MAIN3DS, but some files seem to start with EDIT3DS, with
+// no MAIN3DS
+ if ( ( tshort != MAIN3DS ) && ( tshort != EDIT3DS ) ) {
+ fprintf( stderr,"File is not a 3DS file.\n" );
+ exit( 0 );
+ }
+
+// back to top of file so we can parse the first chunk descriptor
+ fseek( input, 0, SEEK_SET );
+
+ ptri = safe_malloc( MAXTRIANGLES * sizeof( triangle_t ) );
+
+ *pptri = ptri;
+
+// parse through looking for the relevant chunk tree (MAIN3DS | EDIT3DS | EDIT_OBJECT |
+// OBJ_TRIMESH | {TRI_VERTEXL, TRI_FACEL1}) and skipping other chunks
+ ParseChunk( input );
+
+ if ( vertsfound || trisfound ) {
+ Error( "Incomplete triangle set" );
+ }
+
+ *numtriangles = totaltris;
+
+ fclose( input );
+}
--- /dev/null
+/*
+ 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.
+
+ 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.
+
+ 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
+ */
+
+//
+// l3dslib.h: header file for loading triangles from a 3DS triangle file
+//
+void Load3DSTriangleList( char *filename, triangle_t **pptri, int *numtriangles );
--- /dev/null
+/*
+ mdfour.c
+
+ An implementation of MD4 designed for use in the samba SMB
+ authentication protocol
+
+ Copyright (C) 1997-1998 Andrew Tridgell
+
+ This program 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.
+
+ This program 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 this program; if not, write to:
+
+ Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330
+ Boston, MA 02111-1307, USA
+
+ $Id: mdfour.c 7689 2007-11-12 14:28:40Z divverent $
+ */
+
+#include <string.h> /* XoXus: needed for memset call */
+#include "md4.h"
+
+/* NOTE: This code makes no attempt to be fast!
+
+ It assumes that a int is at least 32 bits long
+ */
+
+static struct mdfour *m;
+
+#define F( X,Y,Z ) ( ( (X)&( Y ) ) | ( ( ~( X ) ) & ( Z ) ) )
+#define G( X,Y,Z ) ( ( (X)&( Y ) ) | ( (X)&( Z ) ) | ( (Y)&( Z ) ) )
+#define H( X,Y,Z ) ( ( X ) ^ ( Y ) ^ ( Z ) )
+#ifdef LARGE_INT32
+#define lshift( x,s ) ( ( ( ( x ) << ( s ) ) & 0xFFFFFFFF ) | ( ( ( x ) >> ( 32 - ( s ) ) ) & 0xFFFFFFFF ) )
+#else
+#define lshift( x,s ) ( ( ( x ) << ( s ) ) | ( ( x ) >> ( 32 - ( s ) ) ) )
+#endif
+
+#define ROUND1( a,b,c,d,k,s ) a = lshift( a + F( b,c,d ) + X[k], s )
+#define ROUND2( a,b,c,d,k,s ) a = lshift( a + G( b,c,d ) + X[k] + 0x5A827999,s )
+#define ROUND3( a,b,c,d,k,s ) a = lshift( a + H( b,c,d ) + X[k] + 0x6ED9EBA1,s )
+
+/* this applies md4 to 64 byte chunks */
+static void mdfour64( uint32 *M ){
+ int j;
+ uint32 AA, BB, CC, DD;
+ uint32 X[16];
+ uint32 A,B,C,D;
+
+ for ( j = 0; j < 16; j++ )
+ X[j] = M[j];
+
+ A = m->A; B = m->B; C = m->C; D = m->D;
+ AA = A; BB = B; CC = C; DD = D;
+
+ ROUND1( A,B,C,D, 0, 3 ); ROUND1( D,A,B,C, 1, 7 );
+ ROUND1( C,D,A,B, 2, 11 ); ROUND1( B,C,D,A, 3, 19 );
+ ROUND1( A,B,C,D, 4, 3 ); ROUND1( D,A,B,C, 5, 7 );
+ ROUND1( C,D,A,B, 6, 11 ); ROUND1( B,C,D,A, 7, 19 );
+ ROUND1( A,B,C,D, 8, 3 ); ROUND1( D,A,B,C, 9, 7 );
+ ROUND1( C,D,A,B, 10, 11 ); ROUND1( B,C,D,A, 11, 19 );
+ ROUND1( A,B,C,D, 12, 3 ); ROUND1( D,A,B,C, 13, 7 );
+ ROUND1( C,D,A,B, 14, 11 ); ROUND1( B,C,D,A, 15, 19 );
+
+ ROUND2( A,B,C,D, 0, 3 ); ROUND2( D,A,B,C, 4, 5 );
+ ROUND2( C,D,A,B, 8, 9 ); ROUND2( B,C,D,A, 12, 13 );
+ ROUND2( A,B,C,D, 1, 3 ); ROUND2( D,A,B,C, 5, 5 );
+ ROUND2( C,D,A,B, 9, 9 ); ROUND2( B,C,D,A, 13, 13 );
+ ROUND2( A,B,C,D, 2, 3 ); ROUND2( D,A,B,C, 6, 5 );
+ ROUND2( C,D,A,B, 10, 9 ); ROUND2( B,C,D,A, 14, 13 );
+ ROUND2( A,B,C,D, 3, 3 ); ROUND2( D,A,B,C, 7, 5 );
+ ROUND2( C,D,A,B, 11, 9 ); ROUND2( B,C,D,A, 15, 13 );
+
+ ROUND3( A,B,C,D, 0, 3 ); ROUND3( D,A,B,C, 8, 9 );
+ ROUND3( C,D,A,B, 4, 11 ); ROUND3( B,C,D,A, 12, 15 );
+ ROUND3( A,B,C,D, 2, 3 ); ROUND3( D,A,B,C, 10, 9 );
+ ROUND3( C,D,A,B, 6, 11 ); ROUND3( B,C,D,A, 14, 15 );
+ ROUND3( A,B,C,D, 1, 3 ); ROUND3( D,A,B,C, 9, 9 );
+ ROUND3( C,D,A,B, 5, 11 ); ROUND3( B,C,D,A, 13, 15 );
+ ROUND3( A,B,C,D, 3, 3 ); ROUND3( D,A,B,C, 11, 9 );
+ ROUND3( C,D,A,B, 7, 11 ); ROUND3( B,C,D,A, 15, 15 );
+
+ A += AA; B += BB; C += CC; D += DD;
+
+#ifdef LARGE_INT32
+ A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
+ C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
+#endif
+
+ for ( j = 0; j < 16; j++ )
+ X[j] = 0;
+
+ m->A = A; m->B = B; m->C = C; m->D = D;
+}
+
+static void copy64( uint32 *M, unsigned char *in ){
+ int i;
+
+ for ( i = 0; i < 16; i++ )
+ M[i] = ( in[i * 4 + 3] << 24 ) | ( in[i * 4 + 2] << 16 ) |
+ ( in[i * 4 + 1] << 8 ) | ( in[i * 4 + 0] << 0 );
+}
+
+static void copy4( unsigned char *out,uint32 x ){
+ out[0] = x & 0xFF;
+ out[1] = ( x >> 8 ) & 0xFF;
+ out[2] = ( x >> 16 ) & 0xFF;
+ out[3] = ( x >> 24 ) & 0xFF;
+}
+
+void mdfour_begin( struct mdfour *md ){
+ md->A = 0x67452301;
+ md->B = 0xefcdab89;
+ md->C = 0x98badcfe;
+ md->D = 0x10325476;
+ md->totalN = 0;
+}
+
+
+static void mdfour_tail( unsigned char *in, int n ){
+ unsigned char buf[128];
+ uint32 M[16];
+ uint32 b;
+
+ m->totalN += n;
+
+ b = m->totalN * 8;
+
+ memset( buf, 0, 128 );
+ if ( n ) {
+ memcpy( buf, in, n );
+ }
+ buf[n] = 0x80;
+
+ if ( n <= 55 ) {
+ copy4( buf + 56, b );
+ copy64( M, buf );
+ mdfour64( M );
+ }
+ else {
+ copy4( buf + 120, b );
+ copy64( M, buf );
+ mdfour64( M );
+ copy64( M, buf + 64 );
+ mdfour64( M );
+ }
+}
+
+void mdfour_update( struct mdfour *md, unsigned char *in, int n ){
+ uint32 M[16];
+
+// start of edit by Forest 'LordHavoc' Hale
+// commented out to prevent crashing when length is 0
+// if (n == 0) mdfour_tail(in, n);
+// end of edit by Forest 'LordHavoc' Hale
+
+ m = md;
+
+ while ( n >= 64 ) {
+ copy64( M, in );
+ mdfour64( M );
+ in += 64;
+ n -= 64;
+ m->totalN += 64;
+ }
+
+ mdfour_tail( in, n );
+}
+
+
+void mdfour_result( struct mdfour *md, unsigned char *out ){
+ m = md;
+
+ copy4( out, m->A );
+ copy4( out + 4, m->B );
+ copy4( out + 8, m->C );
+ copy4( out + 12, m->D );
+}
+
+
+void mdfour( unsigned char *out, unsigned char *in, int n ){
+ struct mdfour md;
+ mdfour_begin( &md );
+ mdfour_update( &md, in, n );
+ mdfour_result( &md, out );
+}
+
+///////////////////////////////////////////////////////////////
+// MD4-based checksum utility functions
+//
+// Copyright (C) 2000 Jeff Teunissen <d2deek@pmail.net>
+//
+// Author: Jeff Teunissen <d2deek@pmail.net>
+// Date: 01 Jan 2000
+
+unsigned Com_BlockChecksum( void *buffer, int length ){
+ int digest[4];
+ unsigned val;
+
+ mdfour( (unsigned char *) digest, (unsigned char *) buffer, length );
+
+ val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];
+
+ return val;
+}
+
+void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf ){
+ mdfour( outbuf, (unsigned char *) buffer, len );
+}
--- /dev/null
+/*
+ mdfour.h
+
+ an implementation of MD4 designed for use in the SMB authentication
+ protocol
+
+ Copyright (C) Andrew Tridgell 1997-1998
+
+ This program 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.
+
+ This program 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 this program; if not, write to:
+
+ Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330
+ Boston, MA 02111-1307, USA
+ */
+
+#ifndef _MDFOUR_H
+#define _MDFOUR_H
+
+#ifndef int32
+#define int32 int
+#endif
+
+#if SIZEOF_INT > 4
+#define LARGE_INT32
+#endif
+
+#ifndef uint32
+#define uint32 unsigned int32
+#endif
+
+struct mdfour {
+ uint32 A, B, C, D;
+ uint32 totalN;
+};
+
+void mdfour_begin( struct mdfour *md ); // old: MD4Init
+void mdfour_update( struct mdfour *md, unsigned char *in, int n ); //old: MD4Update
+void mdfour_result( struct mdfour *md, unsigned char *out ); // old: MD4Final
+void mdfour( unsigned char *out, unsigned char *in, int n );
+
+unsigned Com_BlockChecksum( void *buffer, int length );
+void Com_BlockFullChecksum( void *buffer, int len, unsigned char *outbuf );
+
+#endif // _MDFOUR_H
--- /dev/null
+/*
+ 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.
+
+ 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.
+
+ 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
+ */
+#ifndef _THREADS_H
+
+#define _THREADS_H
+
+extern int numthreads;
+
+void ThreadSetDefault( void );
+int GetThreadWork( void );
+void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )( int ) );
+void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) );
+void ThreadLock( void );
+void ThreadUnlock( void );
+
+#endif // _THREADS_H