ref: 1885f38f890e6e85d0dd53f07b9c4f4b02c25073
parent: 3ac792068ec7d81efaea65a60967d23c8b27293a
author: sirjofri <sirjofri@sirjofri.de>
date: Fri Mar 28 06:53:22 EDT 2025
fixes number of tiles calculation
--- a/cache.c
+++ b/cache.c
@@ -19,17 +19,13 @@
}
void
-filly(File *root, int z, int x)
+filly(File *root, int z, int x, int m)
{
- int i, m;
+ int i;
File *f;
char buf[64];
Dir *d;
- m = 1;
- for (i = 0; i < z; i++)
- m *= 2;
-
for (i = 0; i < m; i++) {
snprint(buf, sizeof buf, "%d", i);
f = createfile(root, buf, uid, 0444, mkbundle(z, x, i));
@@ -46,16 +42,12 @@
}
void
-fillx(File *root, int z)
+fillx(File *root, int z, int m)
{
- int i, m;
+ int i;
File *f;
char buf[5];
- m = z*2;
- if (m == 0)
- m = 1;
-
for (i = 0; i < m; i++) {
snprint(buf, sizeof buf, "%d", i);
f = createfile(root, buf, uid, 0777|DMDIR, nil);
@@ -62,7 +54,7 @@
if (!f)
sysfatal("createfile dir %r");
- filly(f, z, i);
+ filly(f, z, i, m);
}
}
@@ -70,15 +62,19 @@
inittree(File *root)
{
File *f;
- int i;
+ int m;
char buf[3];
- for (i = 0; i <= maxzoom; i++) {
+ for (int i = 0; i <= maxzoom; i++) {
snprint(buf, sizeof buf, "%d", i);
f = createfile(root, buf, uid, 0555|DMDIR, nil);
if (!f)
sysfatal("createfile zoomdir %r");
- fillx(f, i);
+
+ m = 1;
+ for (int j = 0; j < i; j++)
+ m *= 2;
+ fillx(f, i, m);
}
}