diff options
author | Daniel Jones <admin@danieljon.es> | 2020-05-13 23:44:39 +0930 |
---|---|---|
committer | Daniel Jones <admin@danieljon.es> | 2020-05-13 23:44:39 +0930 |
commit | 7a92b2306bb70e1551217c77163ae06e84bfdd92 (patch) | |
tree | 9971f3835f219d0e48d52c9317f0c86d77712ae4 | |
parent | b09dd5e059b8038903e507f33641f216ffe6540e (diff) | |
download | websitegenerator-7a92b2306bb70e1551217c77163ae06e84bfdd92.tar.gz websitegenerator-7a92b2306bb70e1551217c77163ae06e84bfdd92.zip |
girl numbers
added 9 10 varients of each girl, now which one is used will be random. there will not be 2 of the same girl on any post
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | pages.c | 11 |
2 files changed, 13 insertions, 1 deletions
@@ -14,12 +14,15 @@ */ #include <stdio.h> +#include <stdlib.h> +#include <time.h> #include "config.h" #include "pages.h" int main(void) { + srand(time(NULL)); for (size_t i = 0; i < sizeof(pages)/sizeof(pages[0]); i++) { if (!pages[i].function(pages[i].flags)) @@ -618,12 +618,21 @@ writeposts(const int *posts, size_t totalposts, const char *outfile, int current if (flags & GIRLNUMBERS) { char num[4] = {0}; /* will never have more than 999 posts */ + int girl_variant = 0; + int used[3] = {-1}; snprintf(num, 4, "%d", post); num[3] = '\0'; fprintf(tmp, "\n<a href='direct/%d.html'>", post); for (int i = 0; i < strlen(num); i++) { - fprintf(tmp, "<img height='70' src=\"%s/%s/%c%s\">", girlnumber_url, girlnumber_dir, num[i], girlnumber_extension); + girl_variant = rand() % 10; + while (girl_variant == used[0] || girl_variant == used[1] || girl_variant == used[2]) + { + /* we don't want duplicate girls on the same line */ + girl_variant = rand() % 10; + } + used[i] = girl_variant; + fprintf(tmp, "<img height='70' src=\"%s/%s/%c_%d%s\">", girlnumber_url, girlnumber_dir, num[i], girl_variant, girlnumber_extension); } fprintf(tmp, "</a>\n"); } |