|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: field.c,v 1.12 2003/05/06 20:48:53 stpohle Exp $ */
|
|
|
|
|
/* $Id: field.c,v 1.13 2003/05/07 00:21:05 stpohle Exp $ */
|
|
|
|
|
/* field.c - procedures which are needed to control the field */
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
@ -376,23 +376,27 @@ field_new (char *filename)
|
|
|
|
|
/* load a random tileset */
|
|
|
|
|
void
|
|
|
|
|
tileset_random () {
|
|
|
|
|
_direntry *destart, *de;
|
|
|
|
|
_direntry *destart, *de, *desel;
|
|
|
|
|
char path[LEN_PATHFILENAME];
|
|
|
|
|
int max, sel;
|
|
|
|
|
|
|
|
|
|
sprintf (path, "%s/tileset", bman.datapath);
|
|
|
|
|
destart = s_getdir (path);
|
|
|
|
|
desel = destart = s_getdir (path);
|
|
|
|
|
|
|
|
|
|
for (max = 0, de = destart; de != NULL; de = de->next)
|
|
|
|
|
if (de->name[0] != '.' && (de->flags & DF_dir) == DF_dir)
|
|
|
|
|
max++;
|
|
|
|
|
|
|
|
|
|
sel = s_random (max);
|
|
|
|
|
for (max = 0, de = destart; max < sel && de != NULL; de = de->next)
|
|
|
|
|
if (de->name[0] != '.' && (de->flags & DF_dir) == DF_dir)
|
|
|
|
|
for (max = 0, de = destart; max <= sel && de != NULL; de = de->next)
|
|
|
|
|
if (de->name[0] != '.' && (de->flags & DF_dir) == DF_dir) {
|
|
|
|
|
desel = de;
|
|
|
|
|
max++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d_printf ("Random Tileset %s (%d)\n", desel->name, sel, max);
|
|
|
|
|
|
|
|
|
|
if (de != NULL)
|
|
|
|
|
strncpy (gfx.tileset, de->name, LEN_TILESETNAME);
|
|
|
|
|
if (desel != NULL)
|
|
|
|
|
strncpy (gfx.tileset, desel->name, LEN_TILESETNAME);
|
|
|
|
|
gfx.tileset[LEN_TILESETNAME-1] = 0;
|
|
|
|
|
}
|
|
|
|
|