mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-18 15:31:48 +00:00
Implement missing client interfaces.
These are: - CL_ResetPrecacheCheck(): Resets the precacher, forces it to reevaluate which assets are available and what needs to be downloaded. - FS_FileInGamedir(): Checks if a file (and only a real file, not somthing in a pak) is available in fs_gamedir. - FS_AddPAKFromGamedir(): Adds a pak in fs_gamedir to the search path.
This commit is contained in:
parent
0a94a8ee92
commit
5d9aefd4ef
5 changed files with 119 additions and 22 deletions
|
@ -442,8 +442,7 @@ void CL_CancelHTTPDownloads (qboolean permKill)
|
|||
|
||||
if (permKill)
|
||||
{
|
||||
// TODO CURL: Haben wir was ähnliches?
|
||||
//CL_ResetPrecacheCheck ();
|
||||
CL_ResetPrecacheCheck();
|
||||
abortDownloads = HTTPDL_ABORT_HARD;
|
||||
}
|
||||
else
|
||||
|
@ -676,9 +675,7 @@ static void CL_CheckAndQueueDownload (char *path)
|
|||
}
|
||||
else
|
||||
{
|
||||
// TODO CURL: Wir haben kein FS_LocalFileExists()
|
||||
//exists = FS_LocalFileExists (path);
|
||||
exists = true;
|
||||
exists = FS_FileInGamedir(path);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1019,18 +1016,14 @@ static void CL_FinishHTTPDownload (void)
|
|||
|
||||
//a pak file is very special...
|
||||
i = strlen (tempName);
|
||||
if ( !strcmp (tempName + i - 4, ".pak") /*|| !strcmp (tempName + i - 4, ".pk3")*/ )
|
||||
{
|
||||
// FS_FlushCache ();
|
||||
// FS_ReloadPAKs ();
|
||||
// Knightmare- just add the pk3/ pak file
|
||||
// if (!strcmp (tempName + i - 4, ".pk3"))
|
||||
// FS_AddPK3File (tempName);
|
||||
// else
|
||||
// TODO CURL: Wir haben kein FS_AddPAKFile().
|
||||
//FS_AddPAKFile (tempName);
|
||||
|
||||
// The list of file types must be consistent with fs_packtypes in filesystem.c.
|
||||
if ( !strcmp (tempName + i - 4, ".pak") || !strcmp (tempName + i - 4, ".pk2") ||
|
||||
!strcmp (tempName + i - 4, ".pk3") || !strcmp (tempName + i - 4, ".zip") )
|
||||
{
|
||||
FS_AddPAKFromGamedir(dl->queueEntry->quakePath);
|
||||
CL_ReVerifyHTTPQueue ();
|
||||
|
||||
downloading_pak = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -434,9 +434,15 @@ int precache_check;
|
|||
int precache_spawncount;
|
||||
int precache_tex;
|
||||
int precache_model_skin;
|
||||
|
||||
byte *precache_model;
|
||||
|
||||
void CL_ResetPrecacheCheck (void)
|
||||
{
|
||||
precache_check = CS_MODELS;
|
||||
precache_model = 0;
|
||||
precache_model_skin = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The server will send this command right
|
||||
* before allowing the client into the server
|
||||
|
|
|
@ -442,6 +442,7 @@ void CL_GetChallengePacket (void);
|
|||
void CL_PingServers_f (void);
|
||||
void CL_Snd_Restart_f (void);
|
||||
void CL_RequestNextDownload (void);
|
||||
void CL_ResetPrecacheCheck (void);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -1273,21 +1273,114 @@ FS_Dir_f(void)
|
|||
|
||||
// --------
|
||||
|
||||
/*
|
||||
* This function returns true if a real file (e.g. not something
|
||||
* in a pak, somthing in the file system itself) exists in the
|
||||
* current gamedir.
|
||||
*/
|
||||
qboolean
|
||||
FS_FileInGamedir(const char *file)
|
||||
{
|
||||
char path[MAX_OSPATH];
|
||||
FILE *fd;
|
||||
|
||||
Com_sprintf(path, sizeof(path), "%s/%s", fs_gamedir, file);
|
||||
|
||||
if ((fd = Q_fopen(path, "rb")) != NULL)
|
||||
{
|
||||
fclose(fd);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function loads the given .pak / .pk3 File from the
|
||||
* fs_gamedir. There's no need to load from other dirs since
|
||||
* fs_gamedir is the only dir written to at runtime.
|
||||
*/
|
||||
qboolean
|
||||
FS_AddPAKFromGamedir(const char *pak)
|
||||
{
|
||||
char path[MAX_OSPATH];
|
||||
|
||||
Com_sprintf(path, sizeof(path), "%s/%s", fs_gamedir, pak);
|
||||
|
||||
// Check of the file really exists.
|
||||
FILE *fd;
|
||||
|
||||
if ((fd = Q_fopen(path, "rb")) == NULL)
|
||||
{
|
||||
assert(fd && "FS_AddPAKfromGamedir() called with nonexisting file");;
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
// Depending on filetype we must load it as .pak or .pk3.
|
||||
for (int i = 0; i < sizeof(fs_packtypes) / sizeof(fs_packtypes[0]); i++)
|
||||
{
|
||||
// Not the current filetype, next one please.
|
||||
if (strncmp(pak + strlen(pak) - strlen(fs_packtypes[i].suffix), fs_packtypes[i].suffix, strlen(fs_packtypes[i].suffix)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fsPack_t *pakfile = NULL;
|
||||
|
||||
switch (fs_packtypes[i].format)
|
||||
{
|
||||
case PAK:
|
||||
pakfile = FS_LoadPAK(path);
|
||||
break;
|
||||
case PK3:
|
||||
pakfile = FS_LoadPK3(path);
|
||||
break;
|
||||
}
|
||||
|
||||
if (pakfile == NULL)
|
||||
{
|
||||
// Couldn't load it.
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add it.
|
||||
fsSearchPath_t *search = Z_Malloc(sizeof(fsSearchPath_t));
|
||||
search->pack = pakfile;
|
||||
search->next = fs_searchPaths;
|
||||
fs_searchPaths = search;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Apparently we didn't load anything.
|
||||
return false;
|
||||
}
|
||||
|
||||
const char*
|
||||
FS_GetNextRawPath(const char* lastRawPath)
|
||||
{
|
||||
assert(fs_rawPath != NULL && "Don't call this if before FS_InitFilesystem()");
|
||||
if(lastRawPath == NULL)
|
||||
|
||||
if (lastRawPath == NULL)
|
||||
{
|
||||
return fs_rawPath->path;
|
||||
}
|
||||
for(fsRawPath_t* rp = fs_rawPath; rp != NULL; rp = rp->next)
|
||||
|
||||
for (fsRawPath_t* rp = fs_rawPath; rp != NULL; rp = rp->next)
|
||||
{
|
||||
if(rp->path == lastRawPath)
|
||||
if (rp->path == lastRawPath)
|
||||
{
|
||||
return (rp->next != NULL) ? rp->next->path : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1326,7 +1419,7 @@ FS_AddDirToSearchPath(char *dir, qboolean create) {
|
|||
search->next = fs_searchPaths;
|
||||
fs_searchPaths = search;
|
||||
|
||||
// We need to add numbered paks in te directory in
|
||||
// We need to add numbered paks in the directory in
|
||||
// sequence and all other paks after them. Otherwise
|
||||
// the gamedata may break.
|
||||
for (i = 0; i < sizeof(fs_packtypes) / sizeof(fs_packtypes[0]); i++) {
|
||||
|
@ -1531,8 +1624,10 @@ FS_BuildGameSpecificSearchPath(char *dir)
|
|||
Qcommon_ExecConfigs(false);
|
||||
|
||||
#ifndef DEDICATED_ONLY
|
||||
// this function is called whenever the game cvar changes => the player wants to switch to another mod
|
||||
// in that case the list of music tracks needs to be loaded again (=> tracks are possibly from the new mod dir)
|
||||
// This function is called whenever the game cvar changes =>
|
||||
// the player wants to switch to another mod. In that case the
|
||||
// list of music tracks needs to be loaded again (=> tracks
|
||||
// are possibly from the new mod dir)
|
||||
OGG_InitTrackList();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -676,6 +676,8 @@ void FS_BuildGameSpecificSearchPath(char *dir);
|
|||
char *FS_Gamedir(void);
|
||||
char *FS_NextPath(char *prevpath);
|
||||
int FS_LoadFile(char *path, void **buffer);
|
||||
qboolean FS_FileInGamedir(const char *file);
|
||||
qboolean FS_AddPAKFromGamedir(const char *pak);
|
||||
const char* FS_GetNextRawPath(const char* lastRawPath);
|
||||
|
||||
/* a null buffer will just return the file length without loading */
|
||||
|
|
Loading…
Reference in a new issue