summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-05-13 23:44:39 +0930
committerDaniel Jones <admin@danieljon.es>2020-05-13 23:44:39 +0930
commit7a92b2306bb70e1551217c77163ae06e84bfdd92 (patch)
tree9971f3835f219d0e48d52c9317f0c86d77712ae4
parentb09dd5e059b8038903e507f33641f216ffe6540e (diff)
downloadwebsitegenerator-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.c3
-rw-r--r--pages.c11
2 files changed, 13 insertions, 1 deletions
diff --git a/main.c b/main.c
index 7e4955b..f4ce096 100644
--- a/main.c
+++ b/main.c
@@ -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))
diff --git a/pages.c b/pages.c
index 8ba3cf4..9e2a9c0 100644
--- a/pages.c
+++ b/pages.c
@@ -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");
}