1
0
Fork 0
forked from fte/fteqw

Support directories with only one demo.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4792 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Circlemaster 2014-11-23 22:44:35 +00:00
parent 4f717b53f4
commit a38b2d607e

View file

@ -705,7 +705,7 @@ qboolean Net_ConnectToDemoDirServer(sv_t* qtv, char *ip)
char demoname[512]; char demoname[512];
int current_demo = 0; int current_demo = 0;
int file_count = 0; int file_count = 0;
int random_number; int random_number = 1; // always this value if the directory contains one file
// 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)
@ -730,7 +730,7 @@ qboolean Net_ConnectToDemoDirServer(sv_t* qtv, char *ip)
if (file_count == 0) if (file_count == 0)
{ {
// empty directory // empty directory
Sys_Printf(qtv->cluster, "Stream %i: Error: Directory is empty.\n", qtv->streamid); Sys_Printf(qtv->cluster, "Stream %i: Error: Directory has no demos.\n", qtv->streamid);
closedir(dir); closedir(dir);
return false; return false;
} }
@ -740,9 +740,12 @@ qboolean Net_ConnectToDemoDirServer(sv_t* qtv, char *ip)
// FIXME: not sure if srand should only be called once somewhere? // FIXME: not sure if srand should only be called once somewhere?
// FIXME: this is not really shuffling the demos, but does introduce some variety // FIXME: this is not really shuffling the demos, but does introduce some variety
srand(time(NULL)); if (file_count > 1)
while ((random_number = rand()%file_count + 1) == qtv->last_random_number); {
qtv->last_random_number = random_number; srand(time(NULL));
while ((random_number = rand()%file_count + 1) == qtv->last_random_number);
qtv->last_random_number = random_number;
}
while (1) { while (1) {
int len; int len;