Fix to ignore non .mvd files in the directory.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4791 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
6c74368870
commit
4f717b53f4
1 changed files with 26 additions and 0 deletions
|
@ -710,6 +710,19 @@ qboolean Net_ConnectToDemoDirServer(sv_t* qtv, char *ip)
|
||||||
// count the files, important for determining a random demo file
|
// count the files, important for determining a random demo file
|
||||||
while ((ent = readdir(dir)) != NULL)
|
while ((ent = readdir(dir)) != NULL)
|
||||||
{
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
// only count files neding in .mvd
|
||||||
|
len = strlen(ent->d_name);
|
||||||
|
if (len < 5)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(ent->d_name+len-4, ".mvd"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (ent->d_type == DT_REG && *(ent->d_name) != '.')
|
if (ent->d_type == DT_REG && *(ent->d_name) != '.')
|
||||||
file_count++; // only add non-hidden and regular files
|
file_count++; // only add non-hidden and regular files
|
||||||
}
|
}
|
||||||
|
@ -732,6 +745,8 @@ qboolean Net_ConnectToDemoDirServer(sv_t* qtv, char *ip)
|
||||||
qtv->last_random_number = random_number;
|
qtv->last_random_number = random_number;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
int len;
|
||||||
|
|
||||||
ent = readdir(dir);
|
ent = readdir(dir);
|
||||||
if (!ent)
|
if (!ent)
|
||||||
{
|
{
|
||||||
|
@ -746,6 +761,17 @@ qboolean Net_ConnectToDemoDirServer(sv_t* qtv, char *ip)
|
||||||
continue; // ignore hidden and non-regular files
|
continue; // ignore hidden and non-regular files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//now make certain that the last four characters are '.mvd' and not something like '.cfg' perhaps
|
||||||
|
len = strlen(ent->d_name);
|
||||||
|
if (len < 5)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp((ent->d_name)+len-4, ".mvd"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (++current_demo != random_number)
|
if (++current_demo != random_number)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue