From f23f8ba96137458e3e6933a0434aa802540ba314 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 18 Mar 2005 06:13:36 +0000 Subject: [PATCH] Small changes. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@903 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/cmd.c | 11 +++------ engine/common/cmd.h | 6 ++--- engine/common/common.c | 52 ++++++++++++++++++++++++++++++++++++++- engine/common/common.h | 1 + engine/common/cvar.c | 2 -- engine/common/gl_q2bsp.c | 11 +++++---- engine/common/mathlib.h | 2 ++ engine/common/particles.h | 3 ++- engine/common/pmove.h | 1 + engine/common/q2pmove.c | 2 +- engine/common/zone.c | 30 +++++++++++++++++++--- engine/common/zone.h | 6 ++--- 12 files changed, 101 insertions(+), 26 deletions(-) diff --git a/engine/common/cmd.c b/engine/common/cmd.c index b46e8300d..23ca5bcf1 100644 --- a/engine/common/cmd.c +++ b/engine/common/cmd.c @@ -955,7 +955,7 @@ static cmd_function_t *cmd_functions; // possible commands to execute Cmd_Argc ============ */ -int Cmd_Argc (void) +int VARGS Cmd_Argc (void) { return cmd_argc; } @@ -965,7 +965,7 @@ int Cmd_Argc (void) Cmd_Argv ============ */ -char *Cmd_Argv (int arg) +char *VARGS Cmd_Argv (int arg) { if ( arg >= cmd_argc ) return cmd_null_string; @@ -980,7 +980,7 @@ Returns a single string containing argv(1) to argv(argc()-1) ============ */ -char *Cmd_Args (void) +char *VARGS Cmd_Args (void) { if (!cmd_args) return ""; @@ -2639,6 +2639,7 @@ void Cmd_Init (void) // register our commands // Cmd_AddCommand ("cfg_save",Cmd_WriteConfig_f); + Cmd_AddCommand ("cfg_load",Cmd_Exec_f); Cmd_AddCommand ("exec",Cmd_Exec_f); @@ -2656,7 +2657,6 @@ void Cmd_Init (void) // Cmd_AddCommand ("msg_trigger", Cmd_Msg_Trigger_f); // Cmd_AddCommand ("filter", Cmd_Msg_Filter_f); - Cmd_AddCommand ("set", Cmd_set_f); Cmd_AddCommand ("seta", Cmd_set_f); Cmd_AddCommand ("inc", Cvar_Inc_f); @@ -2666,10 +2666,8 @@ void Cmd_Init (void) Cmd_AddCommand ("cmdlist", Cmd_List_f); Cmd_AddCommand ("aliaslist", Cmd_AliasList_f); Cmd_AddCommand ("cvarlist", Cvar_List_f); - Cmd_AddCommand ("fs_flush", COM_RefreshFSCache_f); Cvar_Register(&com_fs_cache, "Filesystem"); - Cvar_Register(&tp_disputablemacros, "Teamplay"); #ifndef SERVERONLY @@ -2681,7 +2679,6 @@ void Cmd_Init (void) cmd_maxbuffersize.restriction = RESTRICT_MAX; //filling this causes a loop for quite some time. Cvar_Register(&cl_aliasoverlap, "Console"); - //FIXME: go through quake.rc and parameters looking for sets and setas and setting them now. } diff --git a/engine/common/cmd.h b/engine/common/cmd.h index 8d664bbc1..0e0d61b48 100644 --- a/engine/common/cmd.h +++ b/engine/common/cmd.h @@ -88,9 +88,9 @@ qboolean Cmd_IsCommand (char *line); // attempts to match a partial command for automatic command line completion // returns NULL if nothing fits -int Cmd_Argc (void); -char *Cmd_Argv (int arg); -char *Cmd_Args (void); +int VARGS Cmd_Argc (void); +char *VARGS Cmd_Argv (int arg); +char *VARGS Cmd_Args (void); extern int Cmd_ExecLevel; extern cvar_t cmd_gamecodelevel, cmd_allowaccess; diff --git a/engine/common/common.c b/engine/common/common.c index 323abc93a..77b3398f6 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -336,6 +336,7 @@ char *Q_strlwr(char *s) int Q_strwildcmp(char *s1, char *s2) //2 is wild { + return !wildcmp(s1, s2); while (1) { if (!*s1 && !*s2) @@ -1369,6 +1370,55 @@ char *COM_FileExtension (char *in) return exten; } +//Quake 2's tank model has a borked skin (or two). +void COM_CleanUpPath(char *str) +{ + char *dots; + char *slash; + int critisize = 0; + for (dots = str; *dots; dots++) + { + if (*dots >= 'A' && *dots <= 'Z') + { + *dots = *dots - 'A' + 'a'; + critisize = 1; + } + else if (*dots == '\\') + { + *dots = '/'; + critisize = 2; + } + } + while (dots = strstr(str, "..")) + { + for (slash = dots-2; slash >= str; slash--) + { + if (*slash == '/') + { + memmove(slash, dots+2, strlen(dots+2)+1); + critisize = 3; + break; + } + } + } + while(*str == '/') + { + memmove(str, str+1, strlen(str+1)+1); + critisize = 4; + } + if(critisize) + { + if (critisize == 1) //not a biggy, so not red. + Con_Printf("Please fix file case on your files\n"); + else if (critisize == 2) //you're evil. + Con_Printf("^1NEVER use backslash in a quake filename (we like portability)\n"); + else if (critisize == 3) //compleatly stupid. The main reason why this function exists. Quake2 does it! + Con_Printf("You realise that relative paths are a waste of space?\n"); + else if (critisize == 4) //AAAAHHHHH! (consider sys_error instead) + Con_Printf("^1AAAAAAAHHHH! An absolute path!\n"); + } +} + /* ============ COM_FileBase @@ -3526,7 +3576,7 @@ pack_t *COM_LoadPackFile (char *packfile) CRC_ProcessByte(&crc, ((qbyte *)&info)[j]); */ strcpy (newfiles[i].name, info.name); - Q_strlwr(newfiles[i].name); + COM_CleanUpPath(newfiles[i].name); //blooming tanks. newfiles[i].filepos = LittleLong(info.filepos); newfiles[i].filelen = LittleLong(info.filelen); #ifdef HASH_FILESYSTEM diff --git a/engine/common/common.h b/engine/common/common.h index 9438039fc..84b63baa6 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -234,6 +234,7 @@ void COM_StripExtension (char *in, char *out); void COM_FileBase (char *in, char *out); void COM_DefaultExtension (char *path, char *extension); char *COM_FileExtension (char *in); +void COM_CleanUpPath(char *str); char *VARGS va(char *format, ...); // does a varargs printf into a temp buffer diff --git a/engine/common/cvar.c b/engine/common/cvar.c index dea172bd5..587666160 100644 --- a/engine/common/cvar.c +++ b/engine/common/cvar.c @@ -71,10 +71,8 @@ cvar_group_t *Cvar_GetGroup(char *gname) g = Z_Malloc(sizeof(cvar_group_t)); g->name = gname; g->next = NULL; - g->next = cvar_groups; cvar_groups = g; - return g; } diff --git a/engine/common/gl_q2bsp.c b/engine/common/gl_q2bsp.c index edd590c44..8ef754afd 100644 --- a/engine/common/gl_q2bsp.c +++ b/engine/common/gl_q2bsp.c @@ -1198,6 +1198,7 @@ void CMod_LoadTexInfo (lump_t *l) //yes I know these load from the same place } if (j == texcount) //load a new one { + strlwr(in->texture); _snprintf (name, sizeof(name), "textures/%s.wal", in->texture); out->texture = Mod_LoadWall (name); @@ -1363,7 +1364,7 @@ void CMod_LoadFaces (lump_t *l) out->samples = loadmodel->lightdata + i/3; // set the drawing flags - /* + if (out->texinfo->flags & SURF_WARP) { out->flags |= SURF_DRAWTURB; @@ -1372,9 +1373,9 @@ void CMod_LoadFaces (lump_t *l) out->extents[i] = 16384; out->texturemins[i] = -8192; } - GL_SubdivideSurface (out); // cut up polygon for warps + GL_SubdivideSurface (out, 64); // cut up polygon for warps } - */ + } } #endif @@ -4883,7 +4884,7 @@ void FloodAreaConnections (void) } -void CMQ2_SetAreaPortalState (int portalnum, qboolean open) +void VARGS CMQ2_SetAreaPortalState (int portalnum, qboolean open) { if (mapisq3) Host_Error ("CMQ2_SetAreaPortalState on q3 map"); @@ -4918,7 +4919,7 @@ void CMQ3_SetAreaPortalState (int area1, int area2, qboolean open) } } -qboolean CM_AreasConnected (int area1, int area2) +qboolean VARGS CM_AreasConnected (int area1, int area2) { if (map_noareas.value) return true; diff --git a/engine/common/mathlib.h b/engine/common/mathlib.h index b31f710a4..793a49643 100644 --- a/engine/common/mathlib.h +++ b/engine/common/mathlib.h @@ -106,4 +106,6 @@ void ML_Project (vec3_t in, vec3_t out, vec3_t viewangles, vec3_t vieworg, float void Matrix3_Multiply (vec3_t *in1, vec3_t *in2, vec3_t *out); void Matrix4_Transform3(float *matrix, float *vector, float *product); void ML_ModelViewMatrix(vec3_t modelview, vec3_t viewangles, vec3_t vieworg); +void ML_ModelViewMatrixFromAxis(float *modelview, vec3_t pn, vec3_t right, vec3_t up, vec3_t vieworg); + diff --git a/engine/common/particles.h b/engine/common/particles.h index d8e5d12ed..cf7d0c3fb 100644 --- a/engine/common/particles.h +++ b/engine/common/particles.h @@ -106,7 +106,8 @@ void P_NewServer(void); //allocate a new effect int P_ParticleTypeForName(char *name); -int P_AllocateParticleType(char *name); +int P_AllocateParticleType(char *name); //find one if it exists, or create if it doesn't. +qboolean P_DescriptionIsLoaded(char *name); //returns true if it's usable. void P_SkyTri(float *v1, float *v2, float *v3, struct msurface_s *surf); diff --git a/engine/common/pmove.h b/engine/common/pmove.h index b811c7427..b6c67633e 100644 --- a/engine/common/pmove.h +++ b/engine/common/pmove.h @@ -142,3 +142,4 @@ qboolean PM_TestPlayerPosition (vec3_t point); #ifndef __cplusplus struct trace_s PM_PlayerTrace (vec3_t start, vec3_t stop); #endif + diff --git a/engine/common/q2pmove.c b/engine/common/q2pmove.c index 2c7efd34a..3dbb52c23 100644 --- a/engine/common/q2pmove.c +++ b/engine/common/q2pmove.c @@ -1244,7 +1244,7 @@ Pmove Can be called by either the server or the client ================ */ -void Q2_Pmove (q2pmove_t *pmove) +void VARGS Q2_Pmove (q2pmove_t *pmove) { q2pm = pmove; diff --git a/engine/common/zone.c b/engine/common/zone.c index 5724e5594..b12d61e4b 100644 --- a/engine/common/zone.c +++ b/engine/common/zone.c @@ -151,7 +151,7 @@ int Z_Allocated(void) return used; } -void Z_Free (void *c) +void VARGS Z_Free (void *c) { zone_t *nz; nz = ((zone_t *)((char*)c-ZONEDEBUG))-1; @@ -221,8 +221,31 @@ void BZ_CheckSentinals(void *c) #endif } +void BZ_CheckAllSentinals(void) +{ + zone_t *zone; + for(zone = zone_head; zone; zone=zone->next) + { + int i; + qbyte *buf; + buf = (qbyte *)(zone+1); + for (i = 0; i < ZONEDEBUG; i++) + { + if (buf[i] != sentinalkey) + *(int*)0 = -3; //force a crash... this'll get our attention. + } + buf+=ZONEDEBUG; + //app data + buf += zone->size; + for (i = 0; i < ZONEDEBUG; i++) + { + if (buf[i] != sentinalkey) + *(int*)0 = -3; //force a crash... this'll get our attention. + } + } +} -void Z_FreeTags(int tag) +void VARGS Z_FreeTags(int tag) { zone_t *zone, *next; for(zone = zone_head; zone; zone=next) @@ -286,9 +309,10 @@ void *Z_BaseTagMalloc (int size, int tag, qboolean clear) #ifdef NAMEDMALLOCS strcpy((char *)(nt+1) + nt->size + ZONEDEBUG*2, buffer); #endif + BZ_CheckAllSentinals(); return buf; } -void *Z_TagMalloc (int size, int tag) +void *VARGS Z_TagMalloc (int size, int tag) { #ifdef NAMEDMALLOCS return Z_BaseTagMalloc(size, tag, true, ""); diff --git a/engine/common/zone.h b/engine/common/zone.h index cec14967e..b3bc405fd 100644 --- a/engine/common/zone.h +++ b/engine/common/zone.h @@ -85,12 +85,12 @@ Zone block void Memory_Init (void *buf, int size); -void Z_Free (void *ptr); +void VARGS Z_Free (void *ptr); void *Z_Malloc (int size); // returns 0 filled memory void *Z_MallocNamed (int size, char *, int); // returns 0 filled memory //#define Z_Malloc(x) Z_MallocNamed2(x, __FILE__, __LINE__ ) -void *Z_TagMalloc (int size, int tag); -void Z_FreeTags(int tag); +void *VARGS Z_TagMalloc (int size, int tag); +void VARGS Z_FreeTags(int tag); void Z_DumpHeap (void); void Z_CheckHeap (void);