Fix some stringop-truncation warnings. Enable static freetype in config_fteqw.h. Fix wastes build.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5318 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
49ae9573b8
commit
b68a6218e8
23 changed files with 180 additions and 91 deletions
|
@ -20,7 +20,7 @@ ifeq ($(SVNREVISION),)
|
|||
endif
|
||||
MAKE:=$(MAKE) SVNREVISION=$(SVNREVISION)
|
||||
|
||||
WHOAMI:=$(shell whoami)
|
||||
#WHOAMI:=$(shell whoami)
|
||||
|
||||
|
||||
#update these to download+build a different version. this assumes that the url+subdirs etc contain a consistant version everywhere.
|
||||
|
@ -28,7 +28,7 @@ JPEGVER=9b
|
|||
ZLIBVER=1.2.11
|
||||
PNGVER=1.6.34
|
||||
OGGVER=1.3.3
|
||||
VORBISVER=1.3.5
|
||||
VORBISVER=1.3.6
|
||||
SDL2VER=2.0.7
|
||||
SCINTILLAVER=373
|
||||
OPUSVER=1.2.1
|
||||
|
@ -77,11 +77,14 @@ ifneq (,$(BRANDING))
|
|||
BRANDFLAGS+=-DBRANDING_INC=../game_$(BRANDING).h
|
||||
-include game_$(BRANDING).mak
|
||||
endif
|
||||
ifneq (,$(FTE_CONFIG))
|
||||
export FTE_CONFIG_EXTRA:=$(shell $(CC) -xc -E -P -DFTE_TARGET_$(FTE_TARGET) -DCOMPILE_OPTS common/config_$(FTE_CONFIG).h)
|
||||
BRANDFLAGS+=-DCONFIG_FILE_NAME=config_$(FTE_CONFIG).h $(FTE_CONFIG_EXTRA)
|
||||
EXE_NAME=$(FTE_CONFIG)
|
||||
FTE_CONFIG?=fteqw
|
||||
ifneq ($(FTE_TARGET),vc)
|
||||
ifeq (,$(FTE_CONFIG_EXTRA))
|
||||
export FTE_CONFIG_EXTRA := $(shell $(CC) -xc -E -P -DFTE_TARGET_$(FTE_TARGET) -DCOMPILE_OPTS common/config_$(FTE_CONFIG).h)
|
||||
endif
|
||||
endif
|
||||
BRANDFLAGS+=-DCONFIG_FILE_NAME=config_$(FTE_CONFIG).h $(FTE_CONFIG_EXTRA)
|
||||
EXE_NAME=$(FTE_CONFIG)
|
||||
ifeq (,$(findstring DNO_SPEEX,$(FTE_CONFIG_EXTRA)))
|
||||
USE_SPEEX=1
|
||||
endif
|
||||
|
@ -856,9 +859,9 @@ endif
|
|||
|
||||
COMMONLIBFLAGS=
|
||||
COMMONLDDEPS=
|
||||
CLIENTLIBFLAGS=$(COMMONLIBFLAGS) $(LIBOPUS_STATIC) $(LIBSPEEX_STATIC) $(OGGVORBISFILE_STATIC) $(LIBFREETYPE_STATIC)
|
||||
CLIENTLIBFLAGS=$(COMMONLIBFLAGS) $(LIBOPUS_STATIC) $(LIBSPEEX_STATIC) $(OGGVORBISFILE_STATIC)
|
||||
SERVERLIBFLAGS=$(COMMONLIBFLAGS)
|
||||
CLIENTLDDEPS=$(COMMONLDDEPS) $(LIBOPUS_LDFLAGS) $(LIBSPEEX_LDFLAGS) $(OGGVORBISLDFLAGS) $(LIBFREETYPE_LDFLAGS)
|
||||
CLIENTLDDEPS=$(COMMONLDDEPS) $(LIBOPUS_LDFLAGS) $(LIBSPEEX_LDFLAGS) $(OGGVORBISLDFLAGS)
|
||||
SERVERLDDEPS=$(COMMONLDDEPS)
|
||||
ifeq (1,$(USE_OPUS))
|
||||
LIBOPUS_STATIC=-DOPUS_STATIC
|
||||
|
@ -877,12 +880,12 @@ else
|
|||
OGGVORBISFILE_STATIC=
|
||||
endif
|
||||
ifeq (1,$(LINK_FREETYPE))
|
||||
LIBFREETYPE_STATIC=-DFREETYPE_STATIC
|
||||
LIBFREETYPE_LDFLAGS=-lfreetype
|
||||
CLIENTLIBFLAGS+=-DFREETYPE_STATIC
|
||||
CLIENTLDDEPS+=-lfreetype
|
||||
endif
|
||||
ifeq (1,$(LINK_PNG))
|
||||
LIBFREETYPE_STATIC=-DAVAIL_PNG
|
||||
LIBFREETYPE_LDFLAGS=-lpng
|
||||
CLIENTLIBFLAGS+=-DAVAIL_PNG
|
||||
CLIENTLDDEPS+=-lpng
|
||||
endif
|
||||
ifeq (1,$(strip $(INTERNAL_BULLET)))
|
||||
COMMON_OBJS+=com_phys_bullet.o
|
||||
|
@ -1739,6 +1742,7 @@ $(OUT_DIR)/%.mo $(OUT_DIR)/%.d : %.m
|
|||
$(OUT_DIR)/quakedef.h.gch : quakedef.h
|
||||
$(CC) -x c $(ALL_CFLAGS) -o $@ -c $<
|
||||
PRECOMPHEADERS ?= $(OUT_DIR)/quakedef.h.gch
|
||||
ALL_CFLAGS+=-I$(OUT_DIR)
|
||||
|
||||
#addprefix is to add the ./release/server/ part of the object name
|
||||
#foreach is needed as the OBJS is a list of variable names containing object lists.
|
||||
|
@ -2201,7 +2205,7 @@ libs-$(ARCH)/libspeexdsp.a:
|
|||
|
||||
libs-$(ARCH)/libfreetype.a:
|
||||
test -f freetype-$(FREETYPEVER).tar.gz || wget https://download.savannah.gnu.org/releases/freetype/freetype-$(FREETYPEVER).tar.gz
|
||||
-test -f libs-$(ARCH)/libfreetype.a || (mkdir -p libs-$(ARCH) && cd libs-$(ARCH) && tar -xvzf ../freetype-$(FREETYPEVER).tar.gz && cd freetype-$(FREETYPEVER) && CFLAGS="$(CFLAGS) -Os" $(TOOLOVERRIDES) ./configure $(CONFIGARGS) && $(TOOLOVERRIDES) $(MAKE) && cp objs/.libs/libfreetype.a ../ && cp -r include/ ../)
|
||||
-test -f libs-$(ARCH)/libfreetype.a || (mkdir -p libs-$(ARCH) && cd libs-$(ARCH) && tar -xvzf ../freetype-$(FREETYPEVER).tar.gz && cd freetype-$(FREETYPEVER) && CFLAGS="$(CFLAGS) -Os" $(TOOLOVERRIDES) ./configure $(CONFIGARGS) --with-harfbuzz=no && $(TOOLOVERRIDES) $(MAKE) && cp objs/.libs/libfreetype.a ../ && cp -r include/ ../)
|
||||
|
||||
libs-$(ARCH)/libBulletDynamics.a:
|
||||
test -f bullet3-$(BULLETVER).tar.gz || wget https://github.com/bulletphysics/bullet3/archive/$(BULLETVER).tar.gz -O bullet3-$(BULLETVER).tar.gz
|
||||
|
|
|
@ -342,7 +342,8 @@ void BotQueueConsoleMessage(int chatstate, int type, char *message)
|
|||
m->handle = cs->handle;
|
||||
m->time = AAS_Time();
|
||||
m->type = type;
|
||||
strncpy(m->message, message, MAX_MESSAGE_SIZE);
|
||||
strncpy(m->message, message, MAX_MESSAGE_SIZE-1);
|
||||
m->message[MAX_MESSAGE_SIZE-1] = 0;
|
||||
m->next = NULL;
|
||||
if (cs->lastmessage)
|
||||
{
|
||||
|
@ -1458,7 +1459,8 @@ int BotFindMatch(char *str, bot_match_t *match, unsigned long int context)
|
|||
int i;
|
||||
bot_matchtemplate_t *ms;
|
||||
|
||||
strncpy(match->string, str, MAX_MESSAGE_SIZE);
|
||||
strncpy(match->string, str, MAX_MESSAGE_SIZE-1);
|
||||
match->string[MAX_MESSAGE_SIZE-1] = 0;
|
||||
//remove any trailing enters
|
||||
while(strlen(match->string) &&
|
||||
match->string[strlen(match->string)-1] == '\n')
|
||||
|
@ -2117,7 +2119,8 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname)
|
|||
if (pass)
|
||||
{
|
||||
chattype = (bot_chattype_t *) ptr;
|
||||
strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME);
|
||||
strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME-1);
|
||||
chattype->name[MAX_CHATTYPE_NAME-1] = 0;
|
||||
chattype->firstchatmessage = NULL;
|
||||
//add the chat type to the chat
|
||||
chattype->next = chat->types;
|
||||
|
|
|
@ -283,7 +283,8 @@ itemconfig_t *LoadItemConfig(char *filename)
|
|||
LibVarSet( "max_iteminfo", "256" );
|
||||
}
|
||||
|
||||
strncpy( path, filename, MAX_PATH );
|
||||
strncpy( path, filename, MAX_PATH-1 );
|
||||
path[MAX_PATH-1] = 0;
|
||||
PC_SetBaseFolder(BOTFILESBASEFOLDER);
|
||||
source = LoadSourceFile( path );
|
||||
if( !source ) {
|
||||
|
@ -316,7 +317,14 @@ itemconfig_t *LoadItemConfig(char *filename)
|
|||
return NULL;
|
||||
} //end if
|
||||
StripDoubleQuotes(token.string);
|
||||
strncpy(ii->classname, token.string, sizeof(ii->classname)-1);
|
||||
if (strlen(token.string) >= sizeof(ii->classname))
|
||||
{
|
||||
SourceError(source, "more than %d chars\n", sizeof(ii->classname)-1);
|
||||
FreeMemory(ic);
|
||||
FreeSource(source);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(ii->classname, token.string);
|
||||
if (!ReadStructure(source, &iteminfo_struct, (char *) ii))
|
||||
{
|
||||
FreeMemory(ic);
|
||||
|
@ -688,8 +696,11 @@ void BotGoalName(int number, char *name, int size)
|
|||
{
|
||||
if (li->number == number)
|
||||
{
|
||||
strncpy(name, itemconfig->iteminfo[li->iteminfo].name, size-1);
|
||||
name[size-1] = '\0';
|
||||
size_t r = strlen(itemconfig->iteminfo[li->iteminfo].name);
|
||||
if (r > size-1)
|
||||
r = size-1; //truncate...
|
||||
memcpy(name, itemconfig->iteminfo[li->iteminfo].name, r);
|
||||
name[r] = '\0';
|
||||
return;
|
||||
} //end for
|
||||
} //end for
|
||||
|
|
|
@ -219,7 +219,8 @@ weaponconfig_t *LoadWeaponConfig(char *filename)
|
|||
max_projectileinfo = 32;
|
||||
LibVarSet("max_projectileinfo", "32");
|
||||
} //end if
|
||||
strncpy(path, filename, MAX_PATH);
|
||||
strncpy(path, filename, sizeof(path)-1);
|
||||
path[sizeof(path)-1] = 0;
|
||||
PC_SetBaseFolder(BOTFILESBASEFOLDER);
|
||||
source = LoadSourceFile(path);
|
||||
if (!source)
|
||||
|
|
|
@ -75,7 +75,8 @@ void Log_Open(char *filename)
|
|||
botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename);
|
||||
return;
|
||||
} //end if
|
||||
strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE);
|
||||
strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE-1);
|
||||
logfile.filename[MAX_LOGFILENAMESIZE-1] = 0;
|
||||
botimport.Print(PRT_MESSAGE, "Opened log %s\n", logfile.filename);
|
||||
} //end of the function Log_Create
|
||||
//===========================================================================
|
||||
|
|
|
@ -466,6 +466,7 @@ int PC_ReadDefineParms(source_t *source, define_t *define, token_t **parms, int
|
|||
//============================================================================
|
||||
int PC_StringizeTokens(token_t *tokens, token_t *token)
|
||||
{
|
||||
int ret = qtrue;
|
||||
token_t *t;
|
||||
|
||||
token->type = TT_STRING;
|
||||
|
@ -475,10 +476,15 @@ int PC_StringizeTokens(token_t *tokens, token_t *token)
|
|||
strcat(token->string, "\"");
|
||||
for (t = tokens; t; t = t->next)
|
||||
{
|
||||
strncat(token->string, t->string, MAX_TOKEN - strlen(token->string) - 1);
|
||||
if (strlen(token->string)+strlen(t->string) >= MAX_TOKEN-1)
|
||||
{
|
||||
ret = qfalse;
|
||||
break;
|
||||
}
|
||||
strcat(token->string, t->string);
|
||||
} //end for
|
||||
strncat(token->string, "\"", MAX_TOKEN - strlen(token->string) - 1);
|
||||
return qtrue;
|
||||
return ret;
|
||||
} //end of the function PC_StringizeTokens
|
||||
//============================================================================
|
||||
//
|
||||
|
@ -1018,7 +1024,10 @@ int PC_Directive_include(source_t *source)
|
|||
break;
|
||||
} //end if
|
||||
if (token.type == TT_PUNCTUATION && *token.string == '>') break;
|
||||
strncat(path, token.string, MAX_PATH - 1);
|
||||
if (strlen(path) + strlen(token.string) >= MAX_PATH)
|
||||
SourceWarning(source, "#include truncation");
|
||||
else
|
||||
strcat(path, token.string);
|
||||
} //end while
|
||||
if (*token.string != '>')
|
||||
{
|
||||
|
|
|
@ -216,15 +216,21 @@ qboolean ReadChar(source_t *source, fielddef_t *fd, void *p)
|
|||
int ReadString(source_t *source, fielddef_t *fd, void *p)
|
||||
{
|
||||
token_t token;
|
||||
size_t s;
|
||||
|
||||
if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) return 0;
|
||||
//remove the double quotes
|
||||
StripDoubleQuotes(token.string);
|
||||
//copy the string
|
||||
strncpy((char *) p, token.string, MAX_STRINGFIELD);
|
||||
//make sure the string is closed with a zero
|
||||
((char *)p)[MAX_STRINGFIELD-1] = '\0';
|
||||
//
|
||||
s = strlen(token.string);
|
||||
if (s >= MAX_STRINGFIELD)
|
||||
{
|
||||
s = MAX_STRINGFIELD-1;
|
||||
memcpy(p, token.string, s);
|
||||
((char*)p)[s] = 0;
|
||||
return 0; //truncated
|
||||
}
|
||||
strcpy((char*)p, token.string);
|
||||
return 1;
|
||||
} //end of the function ReadString
|
||||
//===========================================================================
|
||||
|
|
|
@ -587,7 +587,7 @@ cvar_t cl_pitchspeed = CVAR("cl_pitchspeed","150");
|
|||
cvar_t cl_anglespeedkey = CVAR("cl_anglespeedkey","1.5");
|
||||
|
||||
|
||||
#define GATHERBIT(bname,bit) if (bname.state[pnum] & 3) {bits |= (1u<<bit);} bname.state[pnum] &= ~2;
|
||||
#define GATHERBIT(bname,bit) if (bname.state[pnum] & 3) {bits |= (1u<<(bit));} bname.state[pnum] &= ~2;
|
||||
void CL_GatherButtons (usercmd_t *cmd, int pnum)
|
||||
{
|
||||
unsigned int bits = 0;
|
||||
|
|
|
@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "pr_common.h"
|
||||
|
||||
extern usercmd_t cl_pendingcmd[MAX_SPLITS];
|
||||
extern cvar_t sv_demo_write_csqc;
|
||||
|
||||
|
||||
static pubprogfuncs_t *csqcprogs;
|
||||
|
@ -6886,7 +6887,9 @@ static void PDECL CSQC_EntSpawn (struct edict_s *e, int loading)
|
|||
ent->xv->dimension_solid = *csqcg.dimension_default;
|
||||
ent->xv->dimension_hit = *csqcg.dimension_default;
|
||||
|
||||
#ifdef HEXEN2
|
||||
ent->xv->drawflags = SCALE_ORIGIN_ORIGIN;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7071,7 +7074,6 @@ static qboolean CSQC_ValidateMainCSProgs(void *file, size_t filesize, unsigned i
|
|||
static void *CSQC_FindMainProgs(size_t *sz, const char *name, unsigned int checksum, size_t checksize)
|
||||
{ //returns a TempFile
|
||||
char newname[MAX_QPATH];
|
||||
extern cvar_t sv_demo_write_csqc;
|
||||
void *file = NULL;
|
||||
|
||||
//the filename we'll cache to
|
||||
|
|
|
@ -2075,7 +2075,7 @@ void QCBUILTIN PF_skel_build_ptr(pubprogfuncs_t *prinst, struct globalvars_s *pr
|
|||
lastbone = firstbone;
|
||||
|
||||
fstate.g[FS_REG].endbone = 0x7fffffff;
|
||||
for (i = 0; i < 4; i++)
|
||||
for (i = 0; i < FRAME_BLENDS; i++)
|
||||
{
|
||||
fstate.g[FS_REG].frame[i] = blends->animation[i];
|
||||
fstate.g[FS_REG].frametime[i] = blends->animationtime[i];
|
||||
|
|
|
@ -1884,7 +1884,7 @@ void Sys_Clipboard_PasteText(clipboardtype_t cbt, void (*callback)(void *cb, cha
|
|||
free(cliputf8);
|
||||
GlobalUnlock(clipboardhandle);
|
||||
CloseClipboard();
|
||||
return cliputf8;
|
||||
return;
|
||||
}
|
||||
|
||||
//failed at the last hurdle
|
||||
|
|
|
@ -2527,6 +2527,7 @@ static void Mod_ClampModelSize(model_t *mod)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef NONSKELETALMODELS
|
||||
#ifndef SERVERONLY
|
||||
static int R_FindTriangleWithEdge (index_t *indexes, int numtris, int start, int end, int ignore)
|
||||
{
|
||||
|
@ -2581,6 +2582,7 @@ static void Mod_CompileTriangleNeighbours(model_t *loadmodel, galiasinfo_t *gali
|
|||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -4788,14 +4788,19 @@ COM_Version_f
|
|||
*/
|
||||
static void COM_Version_f (void)
|
||||
{
|
||||
Con_Printf("\n");
|
||||
Con_Printf("^&F0%s\n", FULLENGINENAME);
|
||||
Con_Printf("%s\n", ENGINEWEBSITE);
|
||||
Con_Printf("%s\n", version_string());
|
||||
|
||||
Con_TPrintf ("Exe: %s %s\n", __DATE__, __TIME__);
|
||||
|
||||
#ifdef SVNREVISION
|
||||
if (strcmp(STRINGIFY(SVNREVISION), "-"))
|
||||
Con_Printf("SVN Revision: %s\n",STRINGIFY(SVNREVISION));
|
||||
#endif
|
||||
#ifdef CONFIG_FILE_NAME
|
||||
Con_Printf("Build config: %s\n\n", STRINGIFY(CONFIG_FILE_NAME));
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
Con_Printf("debug build\n");
|
||||
|
@ -4977,11 +4982,13 @@ static void COM_Version_f (void)
|
|||
#else
|
||||
#ifdef SPEEX_STATIC
|
||||
Con_Printf(" speex");
|
||||
Con_DPrintf("(static)");
|
||||
#else
|
||||
Con_Printf(" speex(dynamic)");
|
||||
#endif
|
||||
#ifdef OPUS_STATIC
|
||||
Con_Printf(" opus");
|
||||
Con_DPrintf("(static)");
|
||||
#else
|
||||
Con_Printf(" opus(dynamic)");
|
||||
#endif
|
||||
|
@ -5019,18 +5026,23 @@ static void COM_Version_f (void)
|
|||
|
||||
Con_Printf("Misc:");
|
||||
#ifdef SUBSERVERS
|
||||
Con_Printf(" mapcluster(enabled)");
|
||||
Con_Printf(" mapcluster");
|
||||
#else
|
||||
Con_DPrintf(" ^h(disabled: mapcluster)^7");
|
||||
#endif
|
||||
#ifndef SERVERONLY
|
||||
#ifdef AVAIL_FREETYPE
|
||||
Con_Printf(" freetype2");
|
||||
#ifdef FREETYPE_STATIC
|
||||
Con_Printf(" freetype2");
|
||||
Con_DPrintf("(static)");
|
||||
#else
|
||||
Con_Printf(" freetype2(dynamic)");
|
||||
#endif
|
||||
#else
|
||||
Con_DPrintf(" ^h(disabled: freetype2)^7");
|
||||
#endif
|
||||
#ifdef AVAIL_OPENAL
|
||||
Con_Printf(" openal");
|
||||
Con_Printf(" openal(dynamic)");
|
||||
#else
|
||||
Con_DPrintf(" ^h(disabled: openal)^7");
|
||||
#endif
|
||||
|
|
|
@ -180,5 +180,9 @@
|
|||
#endif
|
||||
//-DNO_VORBISFILE //disable static vorbisfile
|
||||
|
||||
|
||||
//enable some staticaly linked libraries
|
||||
-DLINK_FREETYPE //international text requires international fonts.
|
||||
|
||||
//-Os //optimise for size instead of speed. less cpu cache needed means that its sometimes faster anyway.
|
||||
#endif
|
||||
|
|
|
@ -35,12 +35,18 @@ extern char **myargv;
|
|||
int QCC_filelength (int handle);
|
||||
int QCC_tell (int handle);
|
||||
|
||||
#if 0//def __GNUC__
|
||||
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
#define WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
int QC_strcasecmp (const char *s1, const char *s2);
|
||||
int QC_strncasecmp(const char *s1, const char *s2, int n);
|
||||
|
||||
void QC_strlcat(char *dest, const char *src, size_t destsize);
|
||||
void QC_strlcpy(char *dest, const char *src, size_t destsize);
|
||||
void QC_strnlcpy(char *dest, const char *src, size_t srclen, size_t destsize);
|
||||
pbool QC_strlcat(char *dest, const char *src, size_t destsize) WARN_UNUSED_RESULT;
|
||||
pbool QC_strlcpy(char *dest, const char *src, size_t destsize) WARN_UNUSED_RESULT;
|
||||
pbool QC_strnlcpy(char *dest, const char *src, size_t srclen, size_t destsize) WARN_UNUSED_RESULT;
|
||||
char *QC_strcasestr(const char *haystack, const char *needle);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -143,39 +143,36 @@ void SetEndian(void)
|
|||
}
|
||||
|
||||
|
||||
void QC_strlcat(char *dest, const char *src, size_t destsize)
|
||||
pbool QC_strlcat(char *dest, const char *src, size_t destsize)
|
||||
{
|
||||
size_t curlen = strlen(dest);
|
||||
if (!destsize)
|
||||
return; //err
|
||||
return false; //err
|
||||
dest += curlen;
|
||||
while(*src && ++curlen < destsize)
|
||||
*dest++ = *src++;
|
||||
// if (*src)
|
||||
// printf("QC_strlcpy: truncation\n");
|
||||
*dest = 0;
|
||||
return !*src;
|
||||
}
|
||||
void QC_strlcpy(char *dest, const char *src, size_t destsize)
|
||||
pbool QC_strlcpy(char *dest, const char *src, size_t destsize)
|
||||
{
|
||||
size_t curlen = 0;
|
||||
if (!destsize)
|
||||
return; //err
|
||||
return false; //err
|
||||
while(*src && ++curlen < destsize)
|
||||
*dest++ = *src++;
|
||||
// if (*src)
|
||||
// printf("QC_strlcpy: truncation\n");
|
||||
*dest = 0;
|
||||
return !*src;
|
||||
}
|
||||
void QC_strnlcpy(char *dest, const char *src, size_t srclen, size_t destsize)
|
||||
pbool QC_strnlcpy(char *dest, const char *src, size_t srclen, size_t destsize)
|
||||
{
|
||||
size_t curlen = 0;
|
||||
if (!destsize)
|
||||
return; //err
|
||||
return false; //err
|
||||
for(; *src && srclen > 0 && ++curlen < destsize; srclen--)
|
||||
*dest++ = *src++;
|
||||
// if (srclen)
|
||||
// printf("QC_strlcpy: truncation\n");
|
||||
*dest = 0;
|
||||
return !srclen;
|
||||
}
|
||||
|
||||
char *QC_strcasestr(const char *haystack, const char *needle)
|
||||
|
|
|
@ -286,10 +286,11 @@ int *pr_cases;
|
|||
QCC_ref_t *pr_casesref;
|
||||
QCC_ref_t *pr_casesref2;
|
||||
|
||||
#define MAX_LABEL_LENGTH 256
|
||||
typedef struct {
|
||||
int statementno;
|
||||
int lineno;
|
||||
char name[256];
|
||||
char name[MAX_LABEL_LENGTH];
|
||||
} gotooperator_t;
|
||||
|
||||
int max_labels;
|
||||
|
@ -793,6 +794,7 @@ static pbool OpAssignsToB(unsigned int op)
|
|||
return false;
|
||||
}
|
||||
#define OpAssignsToA(op) false
|
||||
#ifdef _DEBUG
|
||||
static int OpAssignsCount(unsigned int op)
|
||||
{
|
||||
switch(op)
|
||||
|
@ -855,7 +857,6 @@ static int OpAssignsCount(unsigned int op)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
static void OpAssignsTo_Debug(void)
|
||||
{
|
||||
int i;
|
||||
|
@ -10173,7 +10174,8 @@ static void QCC_PR_GotoStatement (QCC_statement_t *patch2, char *labelname)
|
|||
pr_gotos = realloc(pr_gotos, sizeof(*pr_gotos)*max_gotos);
|
||||
}
|
||||
|
||||
strncpy(pr_gotos[num_gotos].name, labelname, sizeof(pr_gotos[num_gotos].name) -1);
|
||||
if (!QC_strlcpy(pr_gotos[num_gotos].name, labelname, sizeof(pr_gotos[num_gotos].name)))
|
||||
QCC_PR_ParseWarning(WARN_STRINGTOOLONG, "Label name too long");
|
||||
pr_gotos[num_gotos].lineno = pr_source_line;
|
||||
pr_gotos[num_gotos].statementno = patch2 - statements;
|
||||
|
||||
|
|
|
@ -128,10 +128,16 @@ void QCC_PR_AddIncludePath(const char *newinc)
|
|||
{
|
||||
if (!*qccincludedir[i])
|
||||
{
|
||||
pbool trunc;
|
||||
const char *e = newinc + strlen(newinc)-1;
|
||||
QC_strlcpy(qccincludedir[i], newinc, sizeof(qccincludedir));
|
||||
trunc = !QC_strlcpy(qccincludedir[i], newinc, sizeof(qccincludedir));
|
||||
if (*e != '/' && *e != '\\')
|
||||
QC_strlcat(qccincludedir[i], "/", sizeof(qccincludedir));
|
||||
trunc |= !QC_strlcat(qccincludedir[i], "/", sizeof(qccincludedir));
|
||||
if (trunc)
|
||||
{
|
||||
QCC_PR_ParseWarning(WARN_STRINGTOOLONG, "Include path too long.");
|
||||
*qccincludedir[i] = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!strcmp(qccincludedir[i], newinc))
|
||||
|
@ -469,24 +475,25 @@ static void QCC_PR_GetDefinesListEnumerate(void *vctx, void *data)
|
|||
CompilerConstant_t *def = data;
|
||||
char term[8192];
|
||||
size_t termsize;
|
||||
pbool success = true;
|
||||
|
||||
QC_snprintfz(term, sizeof(term), "\n%s", def->name);
|
||||
if (def->numparams >= 0)
|
||||
{
|
||||
int i;
|
||||
QC_strlcat(term, "(", sizeof(term));
|
||||
success &= QC_strlcat(term, "(", sizeof(term));
|
||||
for (i = 0; i < def->numparams; i++)
|
||||
{
|
||||
if (i)
|
||||
QC_strlcat(term, ",", sizeof(term));
|
||||
QC_strlcat(term, def->params[i], sizeof(term));
|
||||
success &= QC_strlcat(term, ",", sizeof(term));
|
||||
success &= QC_strlcat(term, def->params[i], sizeof(term));
|
||||
}
|
||||
QC_strlcat(term, ")", sizeof(term));
|
||||
success &= QC_strlcat(term, ")", sizeof(term));
|
||||
}
|
||||
if (def->value && *def->value)
|
||||
{
|
||||
char *o, *i;
|
||||
QC_strlcat(term, "=", sizeof(term));
|
||||
success &= QC_strlcat(term, "=", sizeof(term));
|
||||
|
||||
//annoying logic to skip whitespace... hopefully it won't fuck stuff up too much.
|
||||
for (o = term+strlen(term), i = def->value; o < term + sizeof(term)-1 && *i; )
|
||||
|
@ -498,6 +505,8 @@ static void QCC_PR_GetDefinesListEnumerate(void *vctx, void *data)
|
|||
}
|
||||
*o = 0;
|
||||
}
|
||||
if (!success) //this define was too long. don't show truncated stuff.
|
||||
return;
|
||||
|
||||
termsize = strlen(term);
|
||||
if (ctx->length + termsize+1 > ctx->buffersize)
|
||||
|
@ -1126,9 +1135,8 @@ static pbool QCC_PR_Precompiler(void)
|
|||
memmove(msg, msg+1, e-(msg+1));
|
||||
msg[e-(msg+1)] = 0;
|
||||
}
|
||||
if (strlen(msg) >= sizeof(QCC_copyright))
|
||||
if (!QC_strlcpy(QCC_copyright, msg, sizeof(QCC_copyright)))
|
||||
QCC_PR_ParseWarning(WARN_STRINGTOOLONG, "Copyright message is too long\n");
|
||||
QC_strlcpy(QCC_copyright, msg, sizeof(QCC_copyright)-1);
|
||||
}
|
||||
else if (!QC_strcasecmp(qcc_token, "compress"))
|
||||
{
|
||||
|
@ -2806,7 +2814,8 @@ static void QCC_PR_LexGrab (void)
|
|||
if (*pr_framemodelname)
|
||||
QCC_PR_MacroFrame(pr_framemodelname, pr_macrovalue, true);
|
||||
|
||||
QC_strlcpy(pr_framemodelname, pr_token, sizeof(pr_framemodelname));
|
||||
if (!QC_strlcpy(pr_framemodelname, pr_token, sizeof(pr_framemodelname)))
|
||||
QCC_PR_ParseWarning (WARN_STRINGTOOLONG, "$modelname name too long");
|
||||
|
||||
i = QCC_PR_FindMacro(pr_framemodelname);
|
||||
if (i)
|
||||
|
@ -3574,7 +3583,8 @@ int QCC_PR_CheckCompConst(void)
|
|||
|| *end == '#')
|
||||
break;
|
||||
}
|
||||
QC_strnlcpy(pr_token, pr_file_p, end-pr_file_p, sizeof(pr_token));
|
||||
if (!QC_strnlcpy(pr_token, pr_file_p, end-pr_file_p, sizeof(pr_token)))
|
||||
return false; //name too long to be a valid macro
|
||||
|
||||
// externs->Printf("%s\n", pr_token);
|
||||
c = pHash_Get(&compconstantstable, pr_token);
|
||||
|
|
|
@ -4567,11 +4567,12 @@ static int QCC_FindQCFiles(const char *sourcedir)
|
|||
}
|
||||
|
||||
|
||||
static void QCC_GenerateRelativePath(char *dest, size_t destsize, char *base, char *relative)
|
||||
static pbool QCC_GenerateRelativePath(char *dest, size_t destsize, char *base, char *relative)
|
||||
{
|
||||
int p;
|
||||
char *s1, *s2;
|
||||
QC_strlcpy (dest, base, destsize);
|
||||
if (!QC_strlcpy (dest, base, destsize))
|
||||
return false;
|
||||
s1 = strchr(dest, '\\');
|
||||
s2 = strchr(dest, '/');
|
||||
if (s2 > s1)
|
||||
|
@ -4607,22 +4608,27 @@ static void QCC_GenerateRelativePath(char *dest, size_t destsize, char *base, ch
|
|||
{
|
||||
if (p)
|
||||
{ //we were still looking for a separator, but didn't find one, so kill the entire path.
|
||||
QC_strlcpy(dest, "", destsize);
|
||||
(void)QC_strlcpy(dest, "", destsize);
|
||||
p--;
|
||||
}
|
||||
else
|
||||
QC_strlcat(dest, "/", destsize);
|
||||
else if (!QC_strlcat(dest, "/", destsize))
|
||||
return false;
|
||||
}
|
||||
QC_strlcat(dest, s2, destsize);
|
||||
if (!QC_strlcat(dest, s2, destsize))
|
||||
return false;
|
||||
|
||||
while (p>0 && strlen(dest)+3 < destsize)
|
||||
while (p>0)
|
||||
{
|
||||
if (strlen(dest)+3 >= destsize)
|
||||
return false;
|
||||
memmove(dest+3, dest, strlen(dest)+1);
|
||||
dest[0] = '.';
|
||||
dest[1] = '.';
|
||||
dest[2] = '/';
|
||||
p--;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *qcccol[COL_MAX];
|
||||
|
@ -4769,7 +4775,7 @@ pbool QCC_main (int argc, char **argv) //as part of the quake engine
|
|||
|
||||
time(&long_time);
|
||||
strftime(QCC_copyright, sizeof(QCC_copyright), "Compiled [%Y/%m/%d]. ", localtime( &long_time ));
|
||||
QC_strlcat(QCC_copyright, QCC_VersionString(), sizeof(QCC_copyright));
|
||||
(void)QC_strlcat(QCC_copyright, QCC_VersionString(), sizeof(QCC_copyright));
|
||||
for (p = 0; p < 5; p++)
|
||||
strcpy(QCC_Packname[p], "");
|
||||
|
||||
|
@ -4913,7 +4919,7 @@ memset(pr_immediate_string, 0, sizeof(pr_immediate_string));
|
|||
|
||||
qccmsrc = NULL;
|
||||
if (!numsourcefiles)
|
||||
{
|
||||
{ //generate an internal .src file from the argument list
|
||||
int i;
|
||||
for (i = 1;i<myargc;i++)
|
||||
{
|
||||
|
@ -4923,10 +4929,10 @@ memset(pr_immediate_string, 0, sizeof(pr_immediate_string));
|
|||
if (!qccmsrc)
|
||||
{
|
||||
qccmsrc = qccHunkAlloc(8192);
|
||||
QC_strlcpy(qccmsrc, "progs.dat\n", 8192);
|
||||
(void)QC_strlcpy(qccmsrc, "progs.dat\n", 8192);
|
||||
}
|
||||
QC_strlcat(qccmsrc, myargv[i], 8192);
|
||||
QC_strlcat(qccmsrc, "\n", 8192);
|
||||
if (!QC_strlcat(qccmsrc, myargv[i], 8192) || !QC_strlcat(qccmsrc, "\n", 8192))
|
||||
QCC_PR_ParseWarning (WARN_STRINGTOOLONG, "Too many files to compile");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -262,7 +262,8 @@ int QC_EnumerateFilesFromBlob(const void *blob, size_t blobsize, void (*cb)(cons
|
|||
|
||||
csize = QC_ReadRawInt(le+18);
|
||||
usize = QC_ReadRawInt(le+22);
|
||||
QC_strlcpy(name, cd+46, (nl+1<sizeof(name))?nl+1:sizeof(name));
|
||||
if (!QC_strlcpy(name, cd+46, (nl+1<sizeof(name))?nl+1:sizeof(name)))
|
||||
continue; //name was too long.
|
||||
|
||||
cb(name, le+30+QC_ReadRawShort(le+26)+QC_ReadRawShort(le+28), csize, method, usize);
|
||||
ret++;
|
||||
|
|
|
@ -3922,7 +3922,6 @@ static void QCBUILTIN PF_checkclient (pubprogfuncs_t *prinst, struct globalvars_
|
|||
void PF_stuffcmd_Internal(int entnum, const char *str, unsigned int flags)
|
||||
{
|
||||
client_t *cl;
|
||||
int slen;
|
||||
unsigned int i;
|
||||
|
||||
if (flags & STUFFCMD_BROADCAST)
|
||||
|
@ -3999,8 +3998,6 @@ void PF_stuffcmd_Internal(int entnum, const char *str, unsigned int flags)
|
|||
}
|
||||
#endif
|
||||
|
||||
slen = strlen(str);
|
||||
|
||||
if (!(flags & STUFFCMD_DEMOONLY))
|
||||
{
|
||||
if (flags & STUFFCMD_UNRELIABLE)
|
||||
|
@ -4013,7 +4010,7 @@ void PF_stuffcmd_Internal(int entnum, const char *str, unsigned int flags)
|
|||
if (!(flags & STUFFCMD_IGNOREINDEMO))
|
||||
if (sv.mvdrecording)
|
||||
{
|
||||
sizebuf_t *msg = MVDWrite_Begin (dem_single, entnum - 1, 2 + slen);
|
||||
sizebuf_t *msg = MVDWrite_Begin (dem_single, entnum - 1, 2 + strlen(str));
|
||||
MSG_WriteByte (msg, svc_stufftext);
|
||||
MSG_WriteString (msg, str);
|
||||
}
|
||||
|
|
|
@ -530,12 +530,18 @@ void SV_Map_f (void)
|
|||
if (!Q_strcasecmp(Cmd_Argv(0), "map_restart"))
|
||||
{
|
||||
const char *arg = Cmd_Argv(1);
|
||||
#ifdef SAVEDGAMES
|
||||
if (!strcmp(arg, "restore")) //hexen2 reload-saved-game
|
||||
;
|
||||
else if (!strcmp(arg, "initial")) //force initial, even if it breaks saved games.
|
||||
*sv.loadgame_on_restart = 0;
|
||||
else if (atof(arg)) //q3's restart-after-delay
|
||||
Con_DPrintf ("map_restart delay not implemented yet\n");
|
||||
else
|
||||
#endif
|
||||
{
|
||||
float delay = atof(arg);
|
||||
if (delay) //q3's restart-after-delay
|
||||
Con_DPrintf ("map_restart delay not implemented yet\n");
|
||||
}
|
||||
Q_strncpyz (level, ".", sizeof(level));
|
||||
startspot = NULL;
|
||||
|
||||
|
|
|
@ -479,7 +479,7 @@ void World_TouchLinks (world_t *w, wedict_t *ent, areanode_t *node)
|
|||
if (!((int)ent->xv->dimension_solid & (int)touch->xv->dimension_hit)) //didn't change did it?...
|
||||
continue;
|
||||
|
||||
w->Event_Touch(w, touch, ent);
|
||||
w->Event_Touch(w, touch, ent, NULL);
|
||||
|
||||
if (ED_ISFREE(ent))
|
||||
break;
|
||||
|
@ -2242,9 +2242,7 @@ static void World_ClipToNetwork (world_t *w, moveclip_t *clip)
|
|||
{
|
||||
touch = &pe->entities[i];
|
||||
|
||||
if (touch->solidsize == ES_SOLID_NOT)
|
||||
continue;
|
||||
else if (touch->solidsize == ES_SOLID_BSP)
|
||||
if (touch->solidsize == ES_SOLID_BSP)
|
||||
{
|
||||
switch(touch->skinnum)
|
||||
{
|
||||
|
@ -2261,6 +2259,12 @@ static void World_ClipToNetwork (world_t *w, moveclip_t *clip)
|
|||
VectorCopy(model->mins, bmins);
|
||||
VectorCopy(model->maxs, bmaxs);
|
||||
}
|
||||
#if 1
|
||||
else
|
||||
continue; //only hit brush ents.
|
||||
#else
|
||||
else if (touch->solidsize == ES_SOLID_NOT)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
if (clip->type & MOVE_NOMONSTERS)
|
||||
|
@ -2269,6 +2273,7 @@ static void World_ClipToNetwork (world_t *w, moveclip_t *clip)
|
|||
model = NULL;
|
||||
COM_DecodeSize(touch->solidsize, bmins, bmaxs);
|
||||
}
|
||||
#endif
|
||||
if (!(clip->hitcontentsmask & touchcontents))
|
||||
continue;
|
||||
|
||||
|
@ -2325,7 +2330,10 @@ static void World_ClipToNetwork (world_t *w, moveclip_t *clip)
|
|||
if (clip->trace.startsolid && !trace.startsolid)
|
||||
trace.ent = clip->trace.ent; //something else hit earlier, that one gets the trace entity, but not the fraction. yeah, combining traces like this was always going to be weird.
|
||||
else
|
||||
trace.ent = touch;
|
||||
{
|
||||
trace.ent = NULL;
|
||||
clip->trace.entnum = touch->number;
|
||||
}
|
||||
clip->trace = trace;
|
||||
}
|
||||
else if (trace.startsolid || trace.allsolid)
|
||||
|
@ -2336,7 +2344,8 @@ static void World_ClipToNetwork (world_t *w, moveclip_t *clip)
|
|||
if (!clip->trace.ent || trace.fraction == clip->trace.fraction) //xonotic requires that second test (DP has no check at all, which would end up reporting mismatched fraction/ent results, so yuck).
|
||||
{
|
||||
clip->trace.contents = trace.contents;
|
||||
clip->trace.ent = touch;
|
||||
clip->trace.ent = NULL;
|
||||
clip->trace.entnum = touch->number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue