subdivide files

This commit is contained in:
Garux 2021-09-13 22:29:44 +03:00
parent dbeb2d0718
commit e1186dd734
24 changed files with 233 additions and 178 deletions

View File

@ -21,7 +21,9 @@
#include "aselib.h"
#include "cmdlib.h"
#include "inout.h"
#include "qstringops.h"
#include <assert.h>
#include <stdio.h>

View File

@ -20,8 +20,6 @@
*/
#include "cmdlib.h"
#include "mathlib.h"
#include "polyset.h"
void ASE_Load( const char *filename, bool verbose, bool meshanims );

View File

@ -21,6 +21,7 @@
#include "cmdlib.h"
#include "qstringops.h"
#include "mathlib.h"
#include "inout.h"
#include "bspfile.h"

View File

@ -30,6 +30,7 @@
#include "cmdlib.h"
#include "inout.h"
#include "qstringops.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -45,7 +46,6 @@
#define BASEDIRNAME "quake" // assumed to have a 2 or 3 following
#ifdef SAFE_MALLOC
// FIXME switch to -std=c99 or above to use proper %zu format specifier for size_t
void_ptr safe_malloc( size_t size ){
void *p = malloc( size );
if ( !p ) {
@ -324,63 +324,6 @@ int FileTime( const char *path ){
//http://stackoverflow.com/questions/27303062/strstr-function-like-that-ignores-upper-or-lower-case
//chux: Somewhat tricky to match the corner cases of strstr() with inputs like "x","", "","x", "",""
const char *strIstr( const char* haystack, const char* needle ) {
do {
const char* h = haystack;
const char* n = needle;
while ( tolower( (unsigned char)*h ) == tolower( (unsigned char)*n ) && *n != '\0' ) {
h++;
n++;
}
if ( *n == '\0' ) {
return haystack;
}
} while ( *haystack++ );
return NULL;
}
char *strIstr( char* haystack, const char* needle ) {
return const_cast<char*>( strIstr( const_cast<const char*>( haystack ), needle ) );
}
/*
* Copy src to string dst of size size. At most size-1 characters
* will be copied. Always NUL terminates (unless size == 0).
* Returns strlen(src); if retval >= size, truncation occurred.
*/
size_t strcpyQ( char* dest, const char* src, const size_t dest_size ) {
const size_t src_len = strlen( src );
if( src_len < dest_size )
memcpy( dest, src, src_len + 1 );
else if( dest_size != 0 ){
memcpy( dest, src, dest_size - 1 );
dest[dest_size - 1] = '\0';
}
return src_len;
}
size_t strcatQ( char* dest, const char* src, const size_t dest_size ) {
const size_t dest_len = strlen( dest );
return dest_len + strcpyQ( dest + dest_len, src, dest_size > dest_len? dest_size - dest_len : 0 );
}
size_t strncatQ( char* dest, const char* src, const size_t dest_size, const size_t src_len ) {
const size_t dest_len = strlen( dest );
const size_t ds_len = dest_len + src_len;
if( ds_len < dest_size ){
memcpy( dest + dest_len, src, src_len );
dest[ds_len] = '\0';
}
else if( dest_len < dest_size ){
memcpy( dest + dest_len, src, dest_size - dest_len - 1 );
dest[dest_size - 1] = '\0';
}
return ds_len;
}
/*
=============================================================================

View File

@ -91,68 +91,6 @@ void_ptr safe_calloc_info( size_t size, const char* info );
#define offsetof_array( TYPE, ARRAY_MEMBER, ARRAY_SIZE ) ( offsetof( TYPE, ARRAY_MEMBER[0] ) + sizeof( TYPE::ARRAY_MEMBER[0] ) * ARRAY_SIZE )
static inline bool strEmpty( const char* string ){
return *string == '\0';
}
static inline bool strEmptyOrNull( const char* string ){
return string == NULL || *string == '\0';
}
static inline void strClear( char* string ){
*string = '\0';
}
static inline char *strLower( char *string ){
for( char *in = string; *in; ++in )
*in = tolower( *in );
return string;
}
static inline char *copystring( const char *src ){ // version of strdup() with safe_malloc()
const size_t size = strlen( src ) + 1;
return void_ptr( memcpy( safe_malloc( size ), src, size ) );
}
const char* strIstr( const char* haystack, const char* needle );
char* strIstr( char* haystack, const char* needle );
#ifdef WIN32
#define Q_stricmp stricmp
#define Q_strnicmp strnicmp
#else
#define Q_stricmp strcasecmp
#define Q_strnicmp strncasecmp
#endif
static inline bool strEqual( const char* string, const char* other ){
return strcmp( string, other ) == 0;
}
static inline bool strnEqual( const char* string, const char* other, size_t n ){
return strncmp( string, other, n ) == 0;
}
static inline bool striEqual( const char* string, const char* other ){
return Q_stricmp( string, other ) == 0;
}
static inline bool strniEqual( const char* string, const char* other, size_t n ){
return Q_strnicmp( string, other, n ) == 0;
}
static inline bool strEqualPrefix( const char* string, const char* prefix ){
return strnEqual( string, prefix, strlen( prefix ) );
}
static inline bool striEqualPrefix( const char* string, const char* prefix ){
return strniEqual( string, prefix, strlen( prefix ) );
}
static inline bool strEqualSuffix( const char* string, const char* suffix ){
const size_t stringLength = strlen( string );
const size_t suffixLength = strlen( suffix );
return ( suffixLength > stringLength )? false : strnEqual( string + stringLength - suffixLength, suffix, suffixLength );
}
static inline bool striEqualSuffix( const char* string, const char* suffix ){
const size_t stringLength = strlen( string );
const size_t suffixLength = strlen( suffix );
return ( suffixLength > stringLength )? false : strniEqual( string + stringLength - suffixLength, suffix, suffixLength );
}
/* strlcpy, strlcat versions */
size_t strcpyQ( char* dest, const char* src, const size_t dest_size );
size_t strcatQ( char* dest, const char* src, const size_t dest_size );
size_t strncatQ( char* dest, const char* src, const size_t dest_size, const size_t src_len );
void Q_getwd( char *out );
int Q_filelength( FILE *f );
@ -171,12 +109,6 @@ void ExpandWildcards( int *argc, char ***argv );
double I_FloatTime( void );
[[ noreturn ]] void Error( const char *error, ... );
#define ENSURE( condition ) \
(void) \
( (!!( condition )) || \
(Error( "%s:%u:%s: Condition '%s' failed.", __FILE__, __LINE__, __func__, #condition ), 0) )
FILE *SafeOpenWrite( const char *filename, const char *mode = "wb" );
FILE *SafeOpenRead( const char *filename, const char *mode = "rb" );
void SafeRead( FILE *f, void *buffer, int count );

View File

@ -23,6 +23,7 @@
#include "inout.h"
#include "cmdlib.h"
#include "qstringops.h"
#include "etclib.h"
#include "imagelib.h"
#include "vfs.h"

View File

@ -54,7 +54,6 @@ bool verbose = false;
// possibly written to disk at the end of the run
//++timo FIXME: need to be global, required when creating nodes?
xmlDocPtr doc;
xmlNodePtr tree;
// some useful stuff
xmlNodePtr xml_NodeForVec( const Vector3& v ){

View File

@ -19,25 +19,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __INOUT__
#define __INOUT__
// inout is the only stuff relying on xml, include the headers there
#include "libxml/tree.h"
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
// some useful xml routines
xmlNodePtr xml_NodeForVec( const Vector3& 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( const char *msg, int entitynum, int brushnum, bool 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( const char *msg, const Vector3 p[], int numpoints, bool die );
void xml_Point( const char *msg, const Vector3& pt );
#pragma once
void Broadcast_Setup( const char *dest );
void Broadcast_Shutdown();
@ -57,13 +39,8 @@ extern bool verbose;
void Sys_Printf( const char *text, ... );
void Sys_FPrintf( int flag, const char *text, ... );
void Sys_Warning( const char *format, ... );
#ifdef _DEBUG
#define DBG_XML 1
#endif
#ifdef DBG_XML
void DumpXML();
#endif
#endif
[[ noreturn ]] void Error( const char *error, ... );
#define ENSURE( condition ) \
(void) \
( (!!( condition )) || \
(Error( "%s:%u:%s: Condition '%s' failed.", __FILE__, __LINE__, __func__, #condition ), 0) )

View File

@ -0,0 +1,48 @@
/*
Copyright (C) 1999-2006 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
*/
#pragma once
// inout is the only stuff relying on xml, include the headers there
typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
// some useful xml routines
xmlNodePtr xml_NodeForVec( const Vector3& 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( const char *msg, int entitynum, int brushnum, bool 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( const char *msg, const Vector3 p[], int numpoints, bool die );
void xml_Point( const char *msg, const Vector3& pt );
#ifdef _DEBUG
#define DBG_XML 1
#endif
#ifdef DBG_XML
void DumpXML();
#endif

View File

@ -25,6 +25,8 @@
#define POLYSET_MAXTRIANGLES 4096
#define POLYSET_MAXPOLYSETS 64
#include "mathlib.h"
typedef float st_t[2];
typedef float rgb_t[3];

View File

@ -27,6 +27,8 @@
// This file must be identical in the quake and utils directories
//
#include "mathlib.h"
// surface geometry should not exceed these limits
#define SHADER_MAX_VERTEXES 1000
#define SHADER_MAX_INDEXES ( 6 * SHADER_MAX_VERTEXES )

View File

@ -0,0 +1,139 @@
/*
Copyright (C) 1999-2006 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
*/
#pragma once
#include <string.h>
#include <stdlib.h>
#include <cctype>
inline bool strEmpty( const char* string ){
return *string == '\0';
}
inline bool strEmptyOrNull( const char* string ){
return string == NULL || *string == '\0';
}
inline void strClear( char* string ){
*string = '\0';
}
inline char *strLower( char *string ){
for( char *in = string; *in; ++in )
*in = tolower( *in );
return string;
}
inline char *copystring( const char *src ){ // version of strdup() with malloc()
const size_t size = strlen( src ) + 1;
return static_cast<char*>( memcpy( malloc( size ), src, size ) );
}
#ifdef WIN32
#define Q_stricmp stricmp
#define Q_strnicmp strnicmp
#else
#define Q_stricmp strcasecmp
#define Q_strnicmp strncasecmp
#endif
inline bool strEqual( const char* string, const char* other ){
return strcmp( string, other ) == 0;
}
inline bool strnEqual( const char* string, const char* other, size_t n ){
return strncmp( string, other, n ) == 0;
}
inline bool striEqual( const char* string, const char* other ){
return Q_stricmp( string, other ) == 0;
}
inline bool strniEqual( const char* string, const char* other, size_t n ){
return Q_strnicmp( string, other, n ) == 0;
}
inline bool strEqualPrefix( const char* string, const char* prefix ){
return strnEqual( string, prefix, strlen( prefix ) );
}
inline bool striEqualPrefix( const char* string, const char* prefix ){
return strniEqual( string, prefix, strlen( prefix ) );
}
inline bool strEqualSuffix( const char* string, const char* suffix ){
const size_t stringLength = strlen( string );
const size_t suffixLength = strlen( suffix );
return ( suffixLength > stringLength )? false : strnEqual( string + stringLength - suffixLength, suffix, suffixLength );
}
inline bool striEqualSuffix( const char* string, const char* suffix ){
const size_t stringLength = strlen( string );
const size_t suffixLength = strlen( suffix );
return ( suffixLength > stringLength )? false : strniEqual( string + stringLength - suffixLength, suffix, suffixLength );
}
//http://stackoverflow.com/questions/27303062/strstr-function-like-that-ignores-upper-or-lower-case
//chux: Somewhat tricky to match the corner cases of strstr() with inputs like "x","", "","x", "",""
inline const char *strIstr( const char* haystack, const char* needle ) {
do {
const char* h = haystack;
const char* n = needle;
while ( tolower( (unsigned char)*h ) == tolower( (unsigned char)*n ) && *n != '\0' ) {
h++;
n++;
}
if ( *n == '\0' ) {
return haystack;
}
} while ( *haystack++ );
return NULL;
}
inline char *strIstr( char* haystack, const char* needle ) {
return const_cast<char*>( strIstr( const_cast<const char*>( haystack ), needle ) );
}
/* strlcpy, strlcat versions */
/*
* Copy src to string dst of size size. At most size-1 characters
* will be copied. Always NUL terminates (unless size == 0).
* Returns strlen(src); if retval >= size, truncation occurred.
*/
inline size_t strcpyQ( char* dest, const char* src, const size_t dest_size ) {
const size_t src_len = strlen( src );
if( src_len < dest_size )
memcpy( dest, src, src_len + 1 );
else if( dest_size != 0 ){
memcpy( dest, src, dest_size - 1 );
dest[dest_size - 1] = '\0';
}
return src_len;
}
inline size_t strcatQ( char* dest, const char* src, const size_t dest_size ) {
const size_t dest_len = strlen( dest );
return dest_len + strcpyQ( dest + dest_len, src, dest_size > dest_len? dest_size - dest_len : 0 );
}
inline size_t strncatQ( char* dest, const char* src, const size_t dest_size, const size_t src_len ) {
const size_t dest_len = strlen( dest );
const size_t ds_len = dest_len + src_len;
if( ds_len < dest_size ){
memcpy( dest + dest_len, src, src_len );
dest[ds_len] = '\0';
}
else if( dest_len < dest_size ){
memcpy( dest + dest_len, src, dest_size - dest_len - 1 );
dest[dest_size - 1] = '\0';
}
return ds_len;
}

View File

@ -23,6 +23,7 @@
#include "cmdlib.h"
#include "inout.h"
#include "qstringops.h"
#include "scriplib.h"
#include "vfs.h"

View File

@ -25,6 +25,8 @@
#include <stdio.h>
#include "cmdlib.h"
#include "inout.h"
#include "qstringops.h"
#include "mathlib.h"
#include "polyset.h"
#include "trilib.h"

View File

@ -46,6 +46,7 @@
#include <sys/stat.h>
#include "cmdlib.h"
#include "qstringops.h"
#include "filematch.h"
#include "inout.h"
#include "vfs.h"

View File

@ -19,8 +19,9 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <assert.h>
#include "md3lib.h"
#include "inout.h"
#include "../common/cmdlib.h"
/*
** MD3_ComputeTagFromTri

View File

@ -19,9 +19,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include "../common/cmdlib.h"
#include "mathlib.h"
#include "../common/qfiles.h"
void MD3_Dump( const char *filename );

View File

@ -19,7 +19,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <assert.h>
#include "q3data.h"
//=================================================================

View File

@ -26,6 +26,7 @@
#include <string.h>
#include "../common/cmdlib.h"
#include "../common/qstringops.h"
#define MAX_POLYSETS 64

View File

@ -29,6 +29,8 @@
#include <sys/stat.h>
#include "../common/cmdlib.h"
#include "../common/inout.h"
#include "../common/qstringops.h"
#include "scriplib.h"
#include "mathlib.h"
#include "polyset.h"

View File

@ -284,8 +284,6 @@ static void FixBrushSides( entity_t *e ){
void ProcessWorldModel( void ){
entity_t *e;
xmlNodePtr polyline, leaknode;
char level[ 2 ];
const char *value;
/* sets integer blockSize from worldspawn "_blocksize" key if it exists */
@ -332,17 +330,7 @@ void ProcessWorldModel( void ){
const bool leaked = ( leakStatus != EFloodEntities::Good );
if( leaked ){
Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "**********************\n" );
Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "******* leaked *******\n" );
Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "**********************\n" );
polyline = LeakFile( tree );
leaknode = xmlNewNode( NULL, (const xmlChar*)"message" );
xmlNodeAddContent( leaknode, (const xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline );
level[0] = (int) '0' + SYS_ERR;
level[1] = 0;
xmlSetProp( leaknode, (const xmlChar*)"level", (const xmlChar*)level );
xml_SendNode( leaknode );
Leak_feedback( tree );
if ( leaktest ) {
Sys_FPrintf( SYS_WRN, "--- MAP LEAKED, ABORTING LEAKTEST ---\n" );
exit( 0 );

View File

@ -29,7 +29,8 @@
#include "games.h"
#include "bspfile_ibsp.h"
#include "bspfile_rbsp.h"
#include "cmdlib.h"
#include "qstringops.h"
#include "inout.h"
struct game_default : game_t
{

View File

@ -30,6 +30,7 @@
/* dependencies */
#include "q3map2.h"
#include "libxml/tree.h"
@ -117,3 +118,18 @@ xmlNodePtr LeakFile( const tree_t& tree ){
return xml_node;
}
void Leak_feedback( const tree_t& tree ){
Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "**********************\n" );
Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "******* leaked *******\n" );
Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "**********************\n" );
xmlNodePtr polyline = LeakFile( tree );
xmlNodePtr leaknode = xmlNewNode( NULL, (const xmlChar*)"message" );
xmlNodeAddContent( leaknode, (const xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline );
char level[ 2 ];
level[0] = (int) '0' + SYS_ERR;
level[1] = 0;
xmlSetProp( leaknode, (const xmlChar*)"level", (const xmlChar*)level );
xml_SendNode( leaknode );
}

View File

@ -69,6 +69,7 @@
#include "version.h" /* ttimo: might want to guard that if built outside of the GtkRadiant tree */
#include "cmdlib.h"
#include "qstringops.h"
#include "md5lib.h"
#include "ddslib.h"
@ -77,6 +78,7 @@
#include "imagelib.h"
#include "qthreads.h"
#include "inout.h"
#include "inout_xml.h"
#include "vfs.h"
#include "png.h"
#include "md4.h"
@ -1513,7 +1515,7 @@ void MakeTreePortals( tree_t& tree );
/* leakfile.c */
xmlNodePtr LeakFile( const tree_t& tree );
void Leak_feedback( const tree_t& tree );
/* prtfile.c */