#define MAXN 1024
#define MAXP 512
#define MAXB 512
-#define MAXC 1024
+#define MAXH 1024
#define MAXZ 16
#define MAXJ 32
#define MAXX 16
return (fp->bc < MAXB) ? fp->bc++ : overflow("body");
}
-static int incc(struct s_file *fp)
+static int inch(struct s_file *fp)
{
- return (fp->cc < MAXC) ? fp->cc++ : overflow("coin");
+ return (fp->hc < MAXH) ? fp->hc++ : overflow("item");
}
static int incz(struct s_file *fp)
fp->nc = 0;
fp->pc = 0;
fp->bc = 0;
- fp->cc = 0;
+ fp->hc = 0;
fp->zc = 0;
fp->jc = 0;
fp->xc = 0;
fp->nv = (struct s_node *) calloc(MAXN, sizeof (struct s_node));
fp->pv = (struct s_path *) calloc(MAXP, sizeof (struct s_path));
fp->bv = (struct s_body *) calloc(MAXB, sizeof (struct s_body));
- fp->cv = (struct s_coin *) calloc(MAXC, sizeof (struct s_coin));
+ fp->hv = (struct s_item *) calloc(MAXH, sizeof (struct s_item));
fp->zv = (struct s_goal *) calloc(MAXZ, sizeof (struct s_goal));
fp->jv = (struct s_jump *) calloc(MAXJ, sizeof (struct s_jump));
fp->xv = (struct s_swch *) calloc(MAXX, sizeof (struct s_swch));
v_add(fp->vv[i].p, fp->vv[i].p, p);
}
-static void make_coin(struct s_file *fp,
+static void make_item(struct s_file *fp,
char k[][MAXSTR],
char v[][MAXSTR], int c)
{
- int i, ci = incc(fp);
+ int i, hi = inch(fp);
- struct s_coin *cp = fp->cv + ci;
+ struct s_item *hp = fp->hv + hi;
- cp->p[0] = 0.f;
- cp->p[1] = 0.f;
- cp->p[2] = 0.f;
- cp->n = 1;
+ hp->p[0] = 0.f;
+ hp->p[1] = 0.f;
+ hp->p[2] = 0.f;
+
+ hp->t = ITEM_NONE;
+ hp->n = 0;
for (i = 0; i < c; i++)
{
+ if (strcmp(k[i], "classname") == 0)
+ {
+ if (strcmp(v[i], "light") == 0)
+ hp->t = ITEM_COIN;
+ else if (strcmp(v[i], "item_health_large") == 0)
+ hp->t = ITEM_GROW;
+ else if (strcmp(v[i], "item_health_small") == 0)
+ hp->t = ITEM_SHRINK;
+ }
+
if (strcmp(k[i], "light") == 0)
- sscanf(v[i], "%d", &cp->n);
+ sscanf(v[i], "%d", &hp->n);
if (strcmp(k[i], "origin") == 0)
{
sscanf(v[i], "%d %d %d", &x, &y, &z);
- cp->p[0] = +(float) x / SCALE;
- cp->p[1] = +(float) z / SCALE;
- cp->p[2] = -(float) y / SCALE;
+ hp->p[0] = +(float) x / SCALE;
+ hp->p[1] = +(float) z / SCALE;
+ hp->p[2] = -(float) y / SCALE;
}
}
}
up->w[1] = 0.f;
up->w[2] = 0.f;
- up->a = 90.f;
-
for (i = 0; i < c; i++)
{
if (strcmp(k[i], "radius") == 0)
sscanf(v[i], "%f", &up->r);
- if (strcmp(k[i], "angle") == 0)
- sscanf(v[i], "%f", &up->a);
-
if (strcmp(k[i], "origin") == 0)
{
int x = 0, y = 0, z = 0;
if (t == T_END) break;
}
- if (!strcmp(v[i], "light")) make_coin(fp, k, v, c);
+ if (!strcmp(v[i], "light")) make_item(fp, k, v, c);
+ if (!strcmp(v[i], "item_health_large")) make_item(fp, k, v, c);
+ if (!strcmp(v[i], "item_health_small")) make_item(fp, k, v, c);
if (!strcmp(v[i], "info_camp")) make_swch(fp, k, v, c);
if (!strcmp(v[i], "info_null")) make_bill(fp, k, v, c);
if (!strcmp(v[i], "path_corner")) make_path(fp, k, v, c);
static void dump_file(struct s_file *p, const char *name)
{
+ /* FIXME: Count visible geoms.
+ *
+ * I'm afraid items break this (not sure though) so leaving it out.
+ */
+
+#if 0
int i, j;
+#endif
+ int i;
int c = 0;
int n = 0;
+#if 0
int m = p->rc + p->cc * 128 + (p->zc * p->jc + p->xc) * 32;
+#endif
/* Count the number of solid lumps. */
if ((p->lv[i].fl & 1) == 0)
n++;
+#if 0
/* Count the number of visible geoms. */
for (i = 0; i < p->bc; i++)
m += p->lv[p->bv[i].l0 + j].gc;
m += p->bv[i].gc;
}
+#endif
/* Count the total value of all coins. */
- for (i = 0; i < p->cc; i++)
- c += p->cv[i].n;
+ for (i = 0; i < p->hc; i++)
+ if (p->hv[i].t == ITEM_COIN)
+ c += p->hv[i].n;
+#if 0
printf("%s (%d/%d/$%d)\n"
+#endif
+ printf("%s (%d/$%d)\n"
" mtrl vert edge side texc"
" geom lump path node body\n"
"%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d\n"
- " coin goal view jump swch"
+ " item goal view jump swch"
" bill ball char indx\n"
"%6d%6d%6d%6d%6d%6d%6d%6d%6d\n",
+#if 0
name, n, m, c,
+#endif
+ name, n, c,
p->mc, p->vc, p->ec, p->sc, p->tc,
p->gc, p->lc, p->pc, p->nc, p->bc,
- p->cc, p->zc, p->wc, p->jc, p->xc,
+ p->hc, p->zc, p->wc, p->jc, p->xc,
p->rc, p->uc, p->ac, p->ic);
}