Merge remote-tracking branch 'github/master'

Conflicts:
	.gitignore
	config.py
	libs/synapse/synapse.cpp
	plugins/imagehl/lbmlib.cpp
	plugins/surface_heretic2/surfacedialog.cpp
	plugins/surface_ufoai/surfacedialog.cpp
	radiant/brushscript.cpp
	radiant/main.cpp
	radiant/preferences.cpp
	tools/quake3/common/cmdlib.c
	tools/quake3/common/cmdlib.h
	tools/quake3/q3map2/path_init.c
	windows_compile_guide/index.html
This commit is contained in:
Rudolf Polzer 2012-03-27 12:11:37 +02:00
commit b7e36c120e
9 changed files with 66 additions and 41 deletions

View File

@ -708,7 +708,7 @@ void DBrush::SaveToFile( FILE *pFile ){
( *pp )->texInfo.m_texdef.scale[0], ( *pp )->texInfo.m_texdef.scale[0], ( *pp )->texInfo.m_texdef.scale[0], ( *pp )->texInfo.m_texdef.scale[0],
( *pp )->texInfo.m_texdef.rotate ); ( *pp )->texInfo.m_texdef.rotate );
fprintf( pFile, buffer ); fprintf( pFile, "%s", buffer );
} }
fprintf( pFile, "}\n" ); fprintf( pFile, "}\n" );

View File

@ -393,7 +393,6 @@ void idSplineList::setSelectedPoint( idVec3 *p ) {
const idVec3 *idSplineList::getPosition( long t ) { const idVec3 *idSplineList::getPosition( long t ) {
static idVec3 interpolatedPos; static idVec3 interpolatedPos;
static long lastTime = -1;
int count = splineTime.Num(); int count = splineTime.Num();
if ( count == 0 ) { if ( count == 0 ) {
@ -644,7 +643,6 @@ bool idCameraDef::waitEvent( int index ) {
void idCameraDef::buildCamera() { void idCameraDef::buildCamera() {
int i; int i;
int lastSwitch = 0;
idList<float> waits; idList<float> waits;
idList<int> targets; idList<int> targets;
@ -653,7 +651,6 @@ void idCameraDef::buildCamera() {
// we have a base time layout for the path and the target path // we have a base time layout for the path and the target path
// now we need to layer on any wait or speed changes // now we need to layer on any wait or speed changes
for ( i = 0; i < events.Num(); i++ ) { for ( i = 0; i < events.Num(); i++ ) {
idCameraEvent *ev = events[i];
events[i]->setTriggered( false ); events[i]->setTriggered( false );
switch ( events[i]->getType() ) { switch ( events[i]->getType() ) {
case idCameraEvent::EVENT_TARGET: { case idCameraEvent::EVENT_TARGET: {
@ -864,7 +861,8 @@ void idCameraDef::parse( const char *( *text ) ) {
bool idCameraDef::load( const char *filename ) { bool idCameraDef::load( const char *filename ) {
char *buf; char *buf;
const char *buf_p; const char *buf_p;
int length = FS_ReadFile( filename, (void **)&buf );
FS_ReadFile( filename, (void **)&buf );
if ( !buf ) { if ( !buf ) {
return false; return false;
} }
@ -1363,7 +1361,6 @@ void idSplinePosition::write( fileHandle_t file, const char *p ) {
} }
void idCameraDef::addTarget( const char *name, idCameraPosition::positionType type ) { void idCameraDef::addTarget( const char *name, idCameraPosition::positionType type ) {
const char *text = ( name == NULL ) ? va( "target0%d", numTargets() + 1 ) : name;
idCameraPosition *pos = newFromType( type ); idCameraPosition *pos = newFromType( type );
if ( pos ) { if ( pos ) {
pos->setName( name ); pos->setName( name );

View File

@ -487,9 +487,6 @@ void TestStringClass
i = a.length(); // i == 0 i = a.length(); // i == 0
i = c.length(); // i == 4 i = c.length(); // i == 4
const char *s1 = a.c_str(); // s1 == "\0"
const char *s2 = c.c_str(); // s2 == "test\0"
t = new idStr(); // t->len == 0, t->data == "\0" t = new idStr(); // t->len == 0, t->data == "\0"
delete t; // t == ? delete t; // t == ?

View File

@ -244,7 +244,10 @@ char *ExpandArg( const char *path ){
char *ExpandPath( const char *path ){ char *ExpandPath( const char *path ){
static char full[1024]; static char full[1024];
if ( !*qdir || path[0] == '/' || path[0] == '\\' || path[1] == ':' ) { if ( !qdir ) {
Error( "ExpandPath called without qdir set" );
}
if ( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {
strcpy( full, path ); strcpy( full, path );
return full; return full;
} }
@ -254,7 +257,7 @@ char *ExpandPath( const char *path ){
char *ExpandGamePath( const char *path ){ char *ExpandGamePath( const char *path ){
static char full[1024]; static char full[1024];
if ( !*gamedir ) { if ( !gamedir[0] ) {
Error( "ExpandGamePath called without gamedir set" ); Error( "ExpandGamePath called without gamedir set" );
} }
if ( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) { if ( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {

View File

@ -56,7 +56,7 @@
#ifdef PATH_MAX #ifdef PATH_MAX
#define MAX_OS_PATH PATH_MAX #define MAX_OS_PATH PATH_MAX
#else #else
#define MAX_OS_PATH 1024 #define MAX_OS_PATH 4096
#endif #endif
#define MEM_BLOCKSIZE 4096 #define MEM_BLOCKSIZE 4096

View File

@ -43,6 +43,7 @@
#include "libxml/tree.h" #include "libxml/tree.h"
// utf8 conversion // utf8 conversion
#include <glib.h>
#include <glib/gconvert.h> #include <glib/gconvert.h>
#include <glib/gmem.h> #include <glib/gmem.h>

View File

@ -48,6 +48,38 @@ vec_t Random( void ){
} }
char *Q_strncpyz( char *dst, const char *src, size_t len ) {
if ( len == 0 ) {
abort();
}
strncpy( dst, src, len );
dst[ len - 1 ] = '\0';
return dst;
}
char *Q_strcat( char *dst, size_t dlen, const char *src ) {
size_t n = strlen( dst );
if ( n > dlen ) {
abort(); /* buffer overflow */
}
return Q_strncpyz( dst + n, src, dlen - n );
}
char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
size_t n = strlen( dst );
if ( n > dlen ) {
abort(); /* buffer overflow */
}
return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
}
/* /*
ExitQ3Map() ExitQ3Map()

View File

@ -66,27 +66,22 @@ char *LokiGetHomeDir( void ){
#ifndef Q_UNIX #ifndef Q_UNIX
return NULL; return NULL;
#else #else
static char buf[ 4096 ];
struct passwd pw, *pwp;
char *home; char *home;
uid_t id;
struct passwd *pwd;
static char homeBuf[MAX_OS_PATH]; static char homeBuf[MAX_OS_PATH];
/* get the home environment variable */ /* get the home environment variable */
home = getenv( "HOME" ); home = getenv( "HOME" );
if ( home == NULL ) {
/* do some more digging */ /* look up home dir in password database */
id = getuid(); if(!home)
setpwent();
while ( ( pwd = getpwent() ) != NULL )
{ {
if ( pwd->pw_uid == id ) { if ( getpwuid_r( getuid(), &pw, buf, sizeof( buf ), &pwp ) == 0 ) {
home = pwd->pw_dir; return pw.pw_dir;
break;
} }
} }
endpwent();
}
snprintf( homeBuf, sizeof( homeBuf ), "%s/.", home ); snprintf( homeBuf, sizeof( homeBuf ), "%s/.", home );
@ -130,21 +125,16 @@ void LokiInitPaths( char *argv0 ){
qboolean found; qboolean found;
/* do some path divining */
strcpy( temp, argv0 );
if ( strrchr( argv0, '/' ) ) {
argv0 = strrchr( argv0, '/' ) + 1;
}
else
{
/* get path environment variable */
path = getenv( "PATH" ); path = getenv( "PATH" );
/* minor setup */ /* do some path divining */
last = last0; Q_strncpyz( temp, argv0, sizeof( temp ) );
last[ 0 ] = path[ 0 ]; if ( strrchr( temp, '/' ) ) {
last[ 1 ] = '\0'; argv0 = strrchr( argv0, '/' ) + 1;
}
else if ( path ) {
found = qfalse; found = qfalse;
last = path;
/* go through each : segment of path */ /* go through each : segment of path */
while ( last[ 0 ] != '\0' && found == qfalse ) while ( last[ 0 ] != '\0' && found == qfalse )
@ -160,17 +150,17 @@ void LokiInitPaths( char *argv0 ){
/* found home dir candidate */ /* found home dir candidate */
if ( *path == '~' ) { if ( *path == '~' ) {
strcpy( temp, home ); Q_strncpyz( temp, home, sizeof( temp ) );
path++; path++;
} }
/* concatenate */ /* concatenate */
if ( last > ( path + 1 ) ) { if ( last > ( path + 1 ) ) {
strncat( temp, path, ( last - path ) ); Q_strncat( temp, sizeof( temp ), path, ( last - path ) );
strcat( temp, "/" ); Q_strcat( temp, sizeof( temp ), "/" );
} }
strcat( temp, "./" ); Q_strcat( temp, sizeof( temp ), "./" );
strcat( temp, argv0 ); Q_strcat( temp, sizeof( temp ), argv0 );
/* verify the path */ /* verify the path */
if ( access( temp, X_OK ) == 0 ) { if ( access( temp, X_OK ) == 0 ) {

View File

@ -85,6 +85,8 @@
#include "md4.h" #include "md4.h"
#include <stdlib.h> #include <stdlib.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
/* ------------------------------------------------------------------------------- /* -------------------------------------------------------------------------------
@ -1512,6 +1514,9 @@ surfaceInfo_t;
/* main.c */ /* main.c */
vec_t Random( void ); vec_t Random( void );
char *Q_strncpyz( char *dst, const char *src, size_t len );
char *Q_strcat( char *dst, size_t dlen, const char *src );
char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen );
int BSPInfo( int count, char **fileNames ); int BSPInfo( int count, char **fileNames );
int ScaleBSPMain( int argc, char **argv ); int ScaleBSPMain( int argc, char **argv );
int ConvertMain( int argc, char **argv ); int ConvertMain( int argc, char **argv );