Const-ified string parms for filesystem funcs, function exports, and related func in game DLLs.

This commit is contained in:
Knightmare66 2020-08-11 02:08:18 -04:00
parent af3214312d
commit d9848657dc
22 changed files with 178 additions and 112 deletions

View file

@ -714,7 +714,12 @@ char *vtos (vec3_t v);
float vectoyaw (vec3_t vec);
void vectoangles (vec3_t vec, vec3_t angles);
void vectoangles2 (vec3_t vec, vec3_t angles); // Knightmare added
// Knightmare added
void vectoangles2 (vec3_t vec, vec3_t angles);
void GameDirRelativePath (const char *filename, char *output, size_t outputSize);
void SavegameDirRelativePath (const char *filename, char *output, size_t outputSize);
void CreatePath (const char *path);
// end Knightmare
//
// g_combat.c

View file

@ -629,7 +629,7 @@ qboolean KillBox (edict_t *ent)
}
// Knightmare added
void GameDirRelativePath (char *filename, char *output, size_t outputSize)
void GameDirRelativePath (const char *filename, char *output, size_t outputSize)
{
#ifdef KMQUAKE2_ENGINE_MOD
Com_sprintf(output, outputSize, "%s/%s", gi.GameDir(), filename);
@ -644,4 +644,47 @@ void GameDirRelativePath (char *filename, char *output, size_t outputSize)
Com_sprintf(output, outputSize, "%s/baseq2/%s", basedir->string, filename);
#endif // KMQUAKE2_ENGINE_MOD
}
void SavegameDirRelativePath (const char *filename, char *output, size_t outputSize)
{
#ifdef KMQUAKE2_ENGINE_MOD
Com_sprintf(output, outputSize, "%s/%s", gi.SaveGameDir(), filename);
#else // KMQUAKE2_ENGINE_MOD
cvar_t *basedir, *gamedir;
basedir = gi.cvar("basedir", "", 0);
gamedir = gi.cvar("gamedir", "", 0);
if (strlen(gamedir->string))
Com_sprintf(output, outputSize, "%s/%s/%s", basedir->string, gamedir->string, filename);
else
Com_sprintf(output, outputSize, "%s/baseq2/%s", basedir->string, filename);
#endif // KMQUAKE2_ENGINE_MOD
}
void CreatePath (const char *path)
{
#ifdef KMQUAKE2_ENGINE_MOD
gi.CreatePath (path);
#else // KMQUAKE2_ENGINE_MOD
char tmpBuf[MAX_OSPATH];
char *ofs;
if (strstr(path, "..") || strstr(path, "::") || strstr(path, "\\\\") || strstr(path, "//"))
{
gi.dprintf("WARNING: refusing to create relative path '%s'\n", path);
return;
}
Q_strncpyz (tmpBuf, path, sizeof(tmpBuf));
for (ofs = tmpBuf+1 ; *ofs ; ofs++)
{
if (*ofs == '/' || *ofs == '\\')
{ // create the directory
*ofs = 0;
_mkdir (tmpBuf);
*ofs = '/';
}
}
#endif // KMQUAKE2_ENGINE_MOD
}
// end Knightmare

View file

@ -172,8 +172,8 @@ typedef struct
// Knightmare- support game DLL loading from pak files thru engine
// This can be used to load script files, etc
#ifdef KMQUAKE2_ENGINE_MOD
char **(*ListPak) (char *find, int *num); // Deprecated- DO NOT USE!
int (*LoadFile) (char *name, void **buf);
char **(*ListPak) (const char *find, int *num); // Deprecated- DO NOT USE!
int (*LoadFile) (const char *name, void **buf);
void (*FreeFile) (void *buf);
void (*FreeFileList) (char **list, int n);
int (*OpenFile) (const char *name, fileHandle_t *f, fsMode_t mode);
@ -181,9 +181,9 @@ typedef struct
void (*CloseFile) (fileHandle_t f);
int (*FRead) (void *buffer, int size, fileHandle_t f);
int (*FWrite) (const void *buffer, int size, fileHandle_t f);
char *(*FS_GameDir) (void);
char *(*FS_SaveGameDir) (void);
void (*CreatePath) (char *path);
char *(*GameDir) (void);
char *(*SaveGameDir) (void);
void (*CreatePath) (const char *path);
char **(*GetFileList) (const char *path, const char *extension, int *num);
#endif

View file

@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifdef USE_CURL
/*static*/ enum
enum
{
HTTPDL_ABORT_NONE,
HTTPDL_ABORT_SOFT,

View file

@ -737,9 +737,9 @@ extern void my_bprintf ( int printlevel , char * fmt , ... ) ;
extern qboolean IsIdMap ( void ) ;
extern void G_UseTarget ( edict_t * ent , edict_t * activator , edict_t * target ) ;
extern void Think_Delay_Single ( edict_t * ent ) ;
extern void CreatePath ( char * path ) ;
extern void SavegameDirRelativePath ( char * filename , char * output , size_t outputSize ) ;
extern void GameDirRelativePath ( char * filename , char * output , size_t outputSize ) ;
extern void CreatePath ( const char * path ) ;
extern void SavegameDirRelativePath ( const char * filename , char * output , size_t outputSize ) ;
extern void GameDirRelativePath ( const char * filename , char * output , size_t outputSize ) ;
extern edict_t * LookingAt ( edict_t * ent , int filter , vec3_t endpos , float * range ) ;
extern float AtLeast ( float x , float dx ) ;
extern qboolean point_infront ( edict_t * self , vec3_t point ) ;

View file

@ -1177,11 +1177,11 @@ qboolean point_infront (edict_t *self, vec3_t point);
void AnglesNormalize(vec3_t vec);
float SnapToEights(float x);
// Lazarus
float AtLeast(float x, float dx);
edict_t *LookingAt(edict_t *ent, int filter, vec3_t endpos, float *range);
void GameDirRelativePath(char *filename, char *output, size_t outputSize);
void SavegameDirRelativePath(char *filename, char *output, size_t outputSize);
void CreatePath (char *path);
float AtLeast (float x, float dx);
edict_t *LookingAt (edict_t *ent, int filter, vec3_t endpos, float *range);
void GameDirRelativePath (const char *filename, char *output, size_t outputSize);
void SavegameDirRelativePath (const char *filename, char *output, size_t outputSize);
void CreatePath (const char *path);
void G_UseTarget (edict_t *ent, edict_t *activator, edict_t *target);
qboolean IsIdMap (void); // Knightmare added
void my_bprintf (int printlevel, char *fmt, ...);

View file

@ -867,7 +867,7 @@ edict_t *LookingAt (edict_t *ent, int filter, vec3_t endpos, float *range)
return tr.ent;
}
void GameDirRelativePath(char *filename, char *output, size_t outputSize)
void GameDirRelativePath (const char *filename, char *output, size_t outputSize)
{
#ifdef KMQUAKE2_ENGINE_MOD
Com_sprintf(output, outputSize, "%s/%s", gi.GameDir(), filename);
@ -883,7 +883,7 @@ void GameDirRelativePath(char *filename, char *output, size_t outputSize)
#endif // KMQUAKE2_ENGINE_MOD
}
void SavegameDirRelativePath (char *filename, char *output, size_t outputSize)
void SavegameDirRelativePath (const char *filename, char *output, size_t outputSize)
{
#ifdef KMQUAKE2_ENGINE_MOD
Com_sprintf(output, outputSize, "%s/%s", gi.SaveGameDir(), filename);
@ -899,11 +899,12 @@ void SavegameDirRelativePath (char *filename, char *output, size_t outputSize)
#endif // KMQUAKE2_ENGINE_MOD
}
void CreatePath (char *path)
void CreatePath (const char *path)
{
#ifdef KMQUAKE2_ENGINE_MOD
gi.CreatePath (path);
#else // KMQUAKE2_ENGINE_MOD
char tmpBuf[MAX_OSPATH];
char *ofs;
if (strstr(path, "..") || strstr(path, "::") || strstr(path, "\\\\") || strstr(path, "//"))
@ -911,13 +912,14 @@ void CreatePath (char *path)
gi.dprintf("WARNING: refusing to create relative path '%s'\n", path);
return;
}
Q_strncpyz (tmpBuf, path, sizeof(tmpBuf));
for (ofs = path+1 ; *ofs ; ofs++)
for (ofs = tmpBuf+1 ; *ofs ; ofs++)
{
if (*ofs == '/' || *ofs == '\\')
{ // create the directory
*ofs = 0;
_mkdir (path);
_mkdir (tmpBuf);
*ofs = '/';
}
}

View file

@ -196,8 +196,8 @@ typedef struct
// This can be used to load script files, etc
// Also support open, read/write and closing files
#ifdef KMQUAKE2_ENGINE_MOD
char **(*ListPak) (char *find, int *num); // Deprecated- DO NOT USE!
int (*LoadFile) (char *name, void **buf);
char **(*ListPak) (const char *find, int *num); // Deprecated- DO NOT USE!
int (*LoadFile) (const char *name, void **buf);
void (*FreeFile) (void *buf);
void (*FreeFileList) (char **list, int n);
int (*OpenFile) (const char *name, fileHandle_t *f, fsMode_t mode);
@ -207,9 +207,9 @@ typedef struct
int (*FWrite) (const void *buffer, int size, fileHandle_t f);
char *(*GameDir) (void);
char *(*SaveGameDir) (void);
void (*CreatePath) (char *path);
void (*CreatePath) (const char *path);
char **(*GetFileList) (const char *path, const char *extension, int *num);
// void (*cvar_setdescription) (char *var_name, char *description);
// void (*cvar_setdescription) (char *var_name, const char *description);
#endif
} game_import_t;

View file

@ -512,8 +512,8 @@ SYSTEM SPECIFIC
extern int curtime; // time returned by last Sys_Milliseconds
int Sys_Milliseconds (void);
void Sys_Mkdir (char *path);
void Sys_Rmdir (char *path);
void Sys_Mkdir (const char *path);
void Sys_Rmdir (const char *path);
// large block stack allocation routines
void *Hunk_Begin (size_t maxsize);

View file

@ -118,7 +118,7 @@ int Sys_Milliseconds (void)
return curtime;
}
void Sys_Mkdir (char *path)
void Sys_Mkdir (const char *path)
{
mkdir (path, 0777);
}
@ -126,9 +126,9 @@ void Sys_Mkdir (char *path)
//
// added from Q2E
//
void Sys_Rmdir (char *path)
void Sys_Rmdir (const char *path)
{
rmdir(path);
rmdir (path);
}
/*

View file

@ -1654,9 +1654,9 @@ extern qboolean IsXatrixMap ( void ) ;
extern qboolean IsIdMap ( void ) ;
extern void G_UseTarget ( edict_t * ent , edict_t * activator , edict_t * target ) ;
extern void Think_Delay_Single ( edict_t * ent ) ;
extern void CreatePath ( char * path ) ;
extern void SavegameDirRelativePath ( char * filename , char * output , size_t outputSize ) ;
extern void GameDirRelativePath ( char * filename , char * output , size_t outputSize ) ;
extern void CreatePath ( const char * path ) ;
extern void SavegameDirRelativePath ( const char * filename , char * output , size_t outputSize ) ;
extern void GameDirRelativePath ( const char * filename , char * output , size_t outputSize ) ;
extern edict_t * LookingAt ( edict_t * ent , int filter , vec3_t endpos , float * range ) ;
extern float AtLeast ( float x , float dx ) ;
extern qboolean point_infront ( edict_t * self , vec3_t point ) ;

View file

@ -1210,11 +1210,11 @@ qboolean point_infront (edict_t *self, vec3_t point);
void AnglesNormalize(vec3_t vec);
float SnapToEights(float x);
// Lazarus
float AtLeast(float x, float dx);
edict_t *LookingAt(edict_t *ent, int filter, vec3_t endpos, float *range);
void GameDirRelativePath(char *filename, char *output, size_t outputSize);
void SavegameDirRelativePath(char *filename, char *output, size_t outputSize);
void CreatePath (char *path);
float AtLeast (float x, float dx);
edict_t *LookingAt (edict_t *ent, int filter, vec3_t endpos, float *range);
void GameDirRelativePath (const char *filename, char *output, size_t outputSize);
void SavegameDirRelativePath (const char *filename, char *output, size_t outputSize);
void CreatePath (const char *path);
void G_UseTarget (edict_t *ent, edict_t *activator, edict_t *target);
qboolean IsIdMap (void); // Knightmare added
qboolean IsXatrixMap (void); // Knightmare added

View file

@ -1603,7 +1603,7 @@ void InitiallyDead (edict_t *self)
gi.linkentity(self);
}
#define MAX_SKINS 24 //max is 32, but we only need 24
#define MAX_SKINS 32 // max is 32, and we need all of them!
#define MAX_SKINNAME 64
#include "pak.h"

View file

@ -1054,7 +1054,7 @@ edict_t *LookingAt(edict_t *ent, int filter, vec3_t endpos, float *range)
return tr.ent;
}
void GameDirRelativePath (char *filename, char *output, size_t outputSize)
void GameDirRelativePath (const char *filename, char *output, size_t outputSize)
{
#ifdef KMQUAKE2_ENGINE_MOD
Com_sprintf(output, outputSize, "%s/%s", gi.GameDir(), filename);
@ -1070,7 +1070,7 @@ void GameDirRelativePath (char *filename, char *output, size_t outputSize)
#endif // KMQUAKE2_ENGINE_MOD
}
void SavegameDirRelativePath (char *filename, char *output, size_t outputSize)
void SavegameDirRelativePath (const char *filename, char *output, size_t outputSize)
{
#ifdef KMQUAKE2_ENGINE_MOD
Com_sprintf(output, outputSize, "%s/%s", gi.SaveGameDir(), filename);
@ -1086,11 +1086,12 @@ void SavegameDirRelativePath (char *filename, char *output, size_t outputSize)
#endif // KMQUAKE2_ENGINE_MOD
}
void CreatePath (char *path)
void CreatePath (const char *path)
{
#ifdef KMQUAKE2_ENGINE_MOD
gi.CreatePath (path);
#else // KMQUAKE2_ENGINE_MOD
char tmpBuf[MAX_OSPATH];
char *ofs;
if (strstr(path, "..") || strstr(path, "::") || strstr(path, "\\\\") || strstr(path, "//"))
@ -1098,13 +1099,14 @@ void CreatePath (char *path)
gi.dprintf("WARNING: refusing to create relative path '%s'\n", path);
return;
}
Q_strncpyz (tmpBuf, path, sizeof(tmpBuf));
for (ofs = path+1 ; *ofs ; ofs++)
for (ofs = tmpBuf+1 ; *ofs ; ofs++)
{
if (*ofs == '/' || *ofs == '\\')
{ // create the directory
*ofs = 0;
_mkdir (path);
_mkdir (tmpBuf);
*ofs = '/';
}
}

View file

@ -179,8 +179,8 @@ typedef struct
// Knightmare- support game DLL loading from pak files thru engine
// This can be used to load script files, etc
#ifdef KMQUAKE2_ENGINE_MOD
char **(*ListPak) (char *find, int *num); // Deprecated- DO NOT USE!
int (*LoadFile) (char *name, void **buf);
char **(*ListPak) (const char *find, int *num); // Deprecated- DO NOT USE!
int (*LoadFile) (const char *name, void **buf);
void (*FreeFile) (void *buf);
void (*FreeFileList) (char **list, int n);
int (*OpenFile) (const char *name, fileHandle_t *f, fsMode_t mode);
@ -190,8 +190,9 @@ typedef struct
int (*FWrite) (const void *buffer, int size, fileHandle_t f);
char *(*GameDir) (void);
char *(*SaveGameDir) (void);
void (*CreatePath) (char *path);
void (*CreatePath) (const char *path);
char **(*GetFileList) (const char *path, const char *extension, int *num);
// void (*cvar_setdescription) (char *var_name, const char *description);
#endif
} game_import_t;

View file

@ -168,8 +168,8 @@ Com_FilePath
Returns the path up to, but not including the last /
=================
*/
void Com_FilePath (const char *path, char *dst, int dstSize){
void Com_FilePath (const char *path, char *dst, int dstSize)
{
const char *s, *last;
s = last = path + strlen(path);
@ -219,7 +219,7 @@ FS_TypeFlagForPakItem
Returns bit flag based on pak item's extension.
=================
*/
unsigned int FS_TypeFlagForPakItem (char *itemName)
unsigned int FS_TypeFlagForPakItem (const char *itemName)
{
int i;
char extension[8];
@ -278,8 +278,9 @@ FS_CreatePath
Creates any directories needed to store the given filename
============
*/
void FS_CreatePath (char *path)
void FS_CreatePath (const char *path)
{
char tmpBuf[MAX_OSPATH];
char *ofs;
FS_DPrintf("FS_CreatePath( %s )\n", path);
@ -289,14 +290,15 @@ void FS_CreatePath (char *path)
Com_Printf(S_COLOR_YELLOW"WARNING: refusing to create relative path '%s'\n", path);
return;
}
Q_strncpyz (tmpBuf, path, sizeof(tmpBuf));
for (ofs = path+1 ; *ofs ; ofs++)
for (ofs = tmpBuf+1 ; *ofs ; ofs++)
{
if (*ofs == '/' || *ofs == '\\') // Q2E changed
//if (*ofs == '/')
{ // create the directory
*ofs = 0;
Sys_Mkdir (path);
Sys_Mkdir (tmpBuf);
*ofs = '/';
}
}
@ -304,7 +306,7 @@ void FS_CreatePath (char *path)
// Psychospaz's mod detector
qboolean FS_ModType (char *name)
qboolean FS_ModType (const char *name)
{
fsSearchPath_t *search;
@ -313,7 +315,7 @@ qboolean FS_ModType (char *name)
if (strstr (search->path, name))
return true;
}
return (0);
return false;
}
@ -414,7 +416,7 @@ FS_DeletePath
TODO: delete tree contents
=================
*/
void FS_DeletePath (char *path)
void FS_DeletePath (const char *path)
{
FS_DPrintf("FS_DeletePath( %s )\n", path);
@ -1223,7 +1225,7 @@ FS_ListPak
Generates a listing of the contents of a pak file
=================
*/
char **FS_ListPak (char *find, int *num)
char **FS_ListPak (const char *find, int *num)
{
fsSearchPath_t *search;
//char netpath[MAX_OSPATH];
@ -1607,7 +1609,7 @@ int FS_Tell (fileHandle_t f)
FS_FileExists
================
*/
qboolean FS_FileExists (char *path)
qboolean FS_FileExists (const char *path)
{
fileHandle_t f;
@ -1625,7 +1627,7 @@ qboolean FS_FileExists (char *path)
FS_LocalFileExists
================
*/
qboolean FS_LocalFileExists (char *path)
qboolean FS_LocalFileExists (const char *path)
{
char realPath[MAX_OSPATH];
FILE *f;
@ -1644,7 +1646,7 @@ qboolean FS_LocalFileExists (char *path)
FS_SaveFileExists
================
*/
qboolean FS_SaveFileExists (char *path)
qboolean FS_SaveFileExists (const char *path)
{
char realPath[MAX_OSPATH];
FILE *f;
@ -1663,7 +1665,7 @@ qboolean FS_SaveFileExists (char *path)
FS_DownloadFileExists
================
*/
qboolean FS_DownloadFileExists (char *path)
qboolean FS_DownloadFileExists (const char *path)
{
char realPath[MAX_OSPATH];
FILE *f;
@ -1681,7 +1683,7 @@ qboolean FS_DownloadFileExists (char *path)
FS_CopyFile
================
*/
void FS_CopyFile (char *src, char *dst)
void FS_CopyFile (const char *src, const char *dst)
{
FILE *f1, *f2;
size_t l;
@ -1746,7 +1748,7 @@ Returns file size or -1 if the file is not found.
A NULL buffer will just return the file size without loading.
=================
*/
int FS_LoadFile (char *path, void **buffer)
int FS_LoadFile (const char *path, void **buffer)
{
fileHandle_t f;
byte *buf;
@ -1818,14 +1820,14 @@ Checks against a blacklist to see if a file
should not be loaded from a pak.
=================
*/
qboolean FS_FileInPakBlacklist (char *filename, qboolean isPk3)
qboolean FS_FileInPakBlacklist (const char *filename, qboolean isPk3)
{
int i;
char *compare;
qboolean ignore = false;
qboolean loadExtFirst = false;
compare = filename;
compare = (char *)filename;
if (compare[0] == '/') // remove leading slash
compare++;
@ -2282,7 +2284,7 @@ Should only be called after the final FS_AddGameDirectory() call.
Sets fs_savegamedir, not fs_gamedir, and does not load any pack files.
=================
*/
void FS_AddSaveGameDirectory (char *dir)
void FS_AddSaveGameDirectory (const char *dir)
{
fsSearchPath_t *search;
@ -2319,7 +2321,7 @@ Sets fs_downloaddir, not fs_gamedir, and loads any pack files
in that path by calling FS_AddPaksInDirectory().
=================
*/
void FS_AddDownloadDirectory (char *dir)
void FS_AddDownloadDirectory (const char *dir)
{
fsSearchPath_t *search;
@ -2359,7 +2361,7 @@ FS_NextPath
Allows enumerating all of the directories in the search path
=================
*/
char *FS_NextPath (char *prevPath)
char *FS_NextPath (const char *prevPath)
{
fsSearchPath_t *search;
char *prev, *firstPath;
@ -2398,7 +2400,7 @@ Skips fs_savegamedir and fs_downloaddir,
so as not to load game library from there.
=================
*/
char *FS_NextGamePath (char *prevPath)
char *FS_NextGamePath (const char *prevPath)
{
fsSearchPath_t *search;
char *prev;
@ -2741,7 +2743,7 @@ FS_SetGamedir
Sets the gamedir and path to a different directory.
================
*/
void FS_SetGamedir (char *dir)
void FS_SetGamedir (const char *dir)
{
fsSearchPath_t *next;
qboolean basegame1_loaded = false, basegame2_loaded = false;
@ -2762,7 +2764,7 @@ void FS_SetGamedir (char *dir)
Cvar_Set ("basegame", "");
Com_Printf ("Basegame should be a single filename, not a path\n");
}
if ( !Q_stricmp(fs_basegamedir->string, BASEDIRNAME) || !Q_stricmp(fs_basegamedir->string, dir) )
if ( !Q_stricmp(fs_basegamedir->string, BASEDIRNAME) || !Q_stricmp(fs_basegamedir->string, (char *)dir) )
{
Cvar_Set ("basegame", "");
Com_Printf ("Basegame should not be the same as "BASEDIRNAME" or gamedir.\n");
@ -2778,7 +2780,7 @@ void FS_SetGamedir (char *dir)
Cvar_Set ("basegame2", "");
Com_Printf ("Basegame2 should be a single filename, not a path\n");
}
if ( !Q_stricmp(fs_basegamedir2->string, BASEDIRNAME) || !Q_stricmp(fs_basegamedir2->string, dir)
if ( !Q_stricmp(fs_basegamedir2->string, BASEDIRNAME) || !Q_stricmp(fs_basegamedir2->string, (char *)dir)
|| !Q_stricmp(fs_basegamedir2->string, fs_basegamedir->string) )
{
Cvar_Set ("basegame2", "");
@ -2795,7 +2797,7 @@ void FS_SetGamedir (char *dir)
Cvar_Set ("basegame3", "");
Com_Printf ("Basegame3 should be a single filename, not a path.\n");
}
if ( !Q_stricmp(fs_basegamedir3->string, BASEDIRNAME) || !Q_stricmp(fs_basegamedir3->string, dir)
if ( !Q_stricmp(fs_basegamedir3->string, BASEDIRNAME) || !Q_stricmp(fs_basegamedir3->string, (char *)dir)
|| !Q_stricmp(fs_basegamedir3->string, fs_basegamedir->string) || !Q_stricmp(fs_basegamedir3->string, fs_basegamedir2->string) )
{
Cvar_Set ("basegame3", "");
@ -2879,7 +2881,7 @@ void FS_SetGamedir (char *dir)
FS_AddGameDirectory (va("%s/%s", fs_basedir->string, fs_basegamedir3->string) );
}
Cvar_FullSet ("gamedir", dir, CVAR_SERVERINFO|CVAR_NOSET|CVAR_SAVE_IGNORE);
Cvar_FullSet ("gamedir", (char *)dir, CVAR_SERVERINFO|CVAR_NOSET|CVAR_SAVE_IGNORE);
if (fs_cddir->string[0])
FS_AddGameDirectory (va("%s/%s", fs_cddir->string, dir) );
FS_AddGameDirectory (va("%s/%s", fs_basedir->string, dir) );
@ -2970,13 +2972,13 @@ void FS_ExecAutoexec (void)
FS_ListFiles
================
*/
char **FS_ListFiles (char *findname, int *numfiles, unsigned musthave, unsigned canthave)
char **FS_ListFiles (const char *findname, int *numfiles, unsigned musthave, unsigned canthave)
{
char *s;
int nfiles = 0;
char **list = 0;
s = Sys_FindFirst( findname, musthave, canthave );
s = Sys_FindFirst( (char *)findname, musthave, canthave );
while ( s )
{
if ( s[strlen(s)-1] != '.' )
@ -2996,7 +2998,7 @@ char **FS_ListFiles (char *findname, int *numfiles, unsigned musthave, unsigned
list = malloc( sizeof( char * ) * nfiles );
memset( list, 0, sizeof( char * ) * nfiles );
s = Sys_FindFirst( findname, musthave, canthave );
s = Sys_FindFirst( (char *)findname, musthave, canthave );
nfiles = 0;
while ( s )
{
@ -3040,12 +3042,19 @@ void FS_FreeFileList (char **list, int n)
FS_ItemInList
=================
*/
qboolean FS_ItemInList (char *check, int num, char **list)
qboolean FS_ItemInList (const char *check, int num, const char **list)
{
int i;
for (i=0;i<num;i++)
if (!Q_strcasecmp(check, list[i]))
int i;
if (!check || !list)
return false;
for (i=0; i<num; i++)
{
if (!list[i])
continue;
if ( !Q_strcasecmp((char *)check, (char *)list[i]) )
return true;
}
return false;
}
@ -3054,10 +3063,14 @@ qboolean FS_ItemInList (char *check, int num, char **list)
FS_InsertInList
=================
*/
void FS_InsertInList (char **list, char *insert, int len, int start)
void FS_InsertInList (char **list, const char *insert, int len, int start)
{
int i;
if (!list) return;
int i;
if (!list || !insert) return;
if (len < 1 || start < 0) return;
// if (start >= len) return;
if (start > len) return;
for (i=start; i<len; i++)
{

View file

@ -878,11 +878,11 @@ int FS_Write (const void *buffer, int size, fileHandle_t f);
void FS_Seek (fileHandle_t f, int offset, fsOrigin_t origin);
int FS_FTell (fileHandle_t f);
int FS_Tell (fileHandle_t f);
qboolean FS_FileExists (char *path);
qboolean FS_LocalFileExists (char *path);
qboolean FS_SaveFileExists (char *path);
qboolean FS_DownloadFileExists (char *path);
void FS_CopyFile (char *src, char *dst);
qboolean FS_FileExists (const char *path);
qboolean FS_LocalFileExists (const char *path);
qboolean FS_SaveFileExists (const char *path);
qboolean FS_DownloadFileExists (const char *path);
void FS_CopyFile (const char *src, const char *dst);
void FS_RenameFile (const char *oldPath, const char *newPath);
void FS_DeleteFile (const char *path);
@ -890,29 +890,29 @@ char *FS_GameDir (void);
char *FS_SaveGameDir (void);
char *FS_DownloadDir (void);
char *FS_HomePath (void);
void FS_CreatePath (char *path);
void FS_DeletePath (char *path);
char *FS_NextPath (char *prevPath);
char *FS_NextGamePath (char *prevPath);
char **FS_ListFiles (char *findname, int *numfiles, unsigned musthave, unsigned canthave);
void FS_CreatePath (const char *path);
void FS_DeletePath (const char *path);
char *FS_NextPath (const char *prevPath);
char *FS_NextGamePath (const char *prevPath);
char **FS_ListFiles (const char *findname, int *numfiles, unsigned musthave, unsigned canthave);
void FS_FreeFileList (char **list, int n);
qboolean FS_ItemInList (char *check, int num, char **list);
void FS_InsertInList (char **list, char *insert, int len, int start);
qboolean FS_ItemInList (const char *check, int num, const char **list);
void FS_InsertInList (char **list, const char *insert, int len, int start);
void FS_Dir_f (void);
void FS_ExecAutoexec (void);
int FS_LoadFile (char *path, void **buffer);
int FS_LoadFile (const char *path, void **buffer);
void FS_AddPAKFile (const char *packPath, qboolean isProtected); // add pak file function
void FS_AddPK3File (const char *packPath, qboolean isProtected); // add pk3 file function
char **FS_ListPak (char *find, int *num); // pak list function
char **FS_ListPak (const char *find, int *num); // pak list function
char **FS_GetFileList (const char *path, const char *extension, int *num);
void FS_SetGamedir (char *dir);
void FS_SetGamedir (const char *dir);
char *FS_Gamedir (void);
void FS_FreeFile (void *buffer);
// Psychospaz's mod detector
qboolean FS_ModType (char *name);
qboolean FS_ModType (const char *name);
qboolean FS_RoguePath (void);

View file

@ -985,7 +985,7 @@ void VID_Printf (int print_level, char *str, ...);
// a -1 return means the file does not exist
// NULL can be passed for buf to just determine existance
char **FS_GetFileList (const char *path, const char *extension, int *num);
int FS_LoadFile (char *name, void **buf);
int FS_LoadFile (const char *name, void **buf);
void FS_FreeFile (void *buf);
// gamedir will be the current directory that generated

View file

@ -220,7 +220,7 @@ model_t *Mod_ForName (char *name, qboolean crash)
//
// search the currently loaded models
//
for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
for (i=0, mod=mod_known; i<mod_numknown; i++, mod++)
{
if (!mod->name[0])
continue;
@ -231,7 +231,7 @@ model_t *Mod_ForName (char *name, qboolean crash)
//
// find a free model slot spot
//
for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
for (i=0, mod=mod_known; i<mod_numknown; i++, mod++)
{
if (!mod->name[0])
break; // free spot

View file

@ -149,7 +149,7 @@ int Sys_Milliseconds (void)
return curtime;
}
void Sys_Mkdir (char *path)
void Sys_Mkdir (const char *path)
{
mkdir (path, 0777);
}
@ -157,9 +157,9 @@ void Sys_Mkdir (char *path)
//
// added from Q2E
//
void Sys_Rmdir (char *path)
void Sys_Rmdir (const char *path)
{
rmdir(path);
rmdir (path);
}
/*

View file

@ -134,7 +134,7 @@ int Sys_Milliseconds (void)
return curtime;
}
void Sys_Mkdir (char *path)
void Sys_Mkdir (const char *path)
{
_mkdir (path);
}
@ -142,9 +142,9 @@ void Sys_Mkdir (char *path)
//
// added from Q2E
//
void Sys_Rmdir (char *path)
void Sys_Rmdir (const char *path)
{
_rmdir(path);
_rmdir (path);
}
/*

View file

@ -170,8 +170,8 @@ typedef struct
// Knightmare- support game DLL loading from pak files thru engine
// This can be used to load script files, etc
#ifdef KMQUAKE2_ENGINE_MOD
char **(*ListPak) (char *find, int *num); // Deprecated- DO NOT USE!
int (*LoadFile) (char *name, void **buf);
char **(*ListPak) (const char *find, int *num); // Deprecated- DO NOT USE!
int (*LoadFile) (const char *name, void **buf);
void (*FreeFile) (void *buf);
void (*FreeFileList) (char **list, int n);
int (*OpenFile) (const char *name, fileHandle_t *f, fsMode_t mode);
@ -181,7 +181,7 @@ typedef struct
int (*FWrite) (const void *buffer, int size, fileHandle_t f);
char *(*GameDir) (void);
char *(*SaveGameDir) (void);
void (*CreatePath) (char *path);
void (*CreatePath) (const char *path);
char **(*GetFileList) (const char *path, const char *extension, int *num);
#endif