shithub: sce

Download patch

ref: ab0e509c55d18cf3cd89e46054ec1c975bea1cfe
parent: f446b828e46ce0bb9f975ff864eafbb4a6478c69
author: qwx <qwx@sciops.net>
date: Tue Aug 25 18:59:33 EDT 2020

fs: move pic nr field to pics struct instead of obj where it belongs

--- a/dat.h
+++ b/dat.h
@@ -79,6 +79,7 @@
 	Pic **p;
 	Pic **shadow;
 	int nf;
+	int nr;
 };
 
 enum{
@@ -91,7 +92,6 @@
 	char *name;
 	Pics pidle;
 	Pics pmove;
-	int nr;
 	int w;
 	int h;
 	int f;
--- a/drw.c
+++ b/drw.c
@@ -267,10 +267,10 @@
 	pp = mo->pics;
 	if(notshadow){
 		p = pp->p[tc % pp->nf];
-		p += mo->o->nr * (mo->team-1);
+		p += pp->nr * (mo->team-1);
 	}else
 		p = pp->shadow[tc % pp->nf];
-	p += mo->θ / (Nrot / mo->o->nr);
+	p += mo->θ / (Nrot / pp->nr);
 	return p;
 }
 
--- a/fs.c
+++ b/fs.c
@@ -331,7 +331,7 @@
 		obj = emalloc(nobj * sizeof *obj);
 	o = obj + tab->row;
 	o->name = estrdup(*fld++);
-	unpack(fld, "ddddddddddddaa", &o->nr, &o->f, &o->w, &o->h,
+	unpack(fld, "dddddddddddaa", &o->f, &o->w, &o->h,
 		&o->hp, &o->def, &o->speed, &o->vis,
 		o->cost, o->cost+1, o->cost+2, &o->time,
 		o->atk, o->atk+1);
@@ -342,14 +342,16 @@
 static void
 readspr(char **fld, int n, Table *)
 {
-	int type, id;
+	int type, id, nr;
 	Obj *o;
 	Pics *ps;
 	Pic ***ppp, **p, **pe;
 
-	unpack(fld, "od", &o, &type);
-	fld += 2;
-	n -= 2;
+	if(n < 4)
+		sysfatal("readspr: %d fields < 4 mandatory columns", n);
+	unpack(fld, "odd", &o, &type, &nr);
+	fld += 3;
+	n -= 3;
 	ps = nil;
 	switch(type & 0x7f){
 	case PFidle: ps = &o->pidle; break;
@@ -359,20 +361,22 @@
 	ppp = type & PFshadow ? &ps->shadow : &ps->p;
 	if(*ppp != nil)
 		sysfatal("readspr: %s pic type %#ux already allocated", o->name, type);
-	if(ps->nf != 0 && ps->nf != n)
+	fprint(2, "spr %s f %ux nf %d %d nr %d %d\n", o->name, type, ps->nf, n, ps->nr, nr);
+	if(ps->nf != 0 && ps->nf != n || ps->nr != 0 && ps->nr != nr)
 		sysfatal("readspr: %s spriteset phase error", o->name);
 	ps->nf = n;
+	ps->nr = nr;
 	p = emalloc(n * sizeof *ppp);
 	*ppp = p;
 	for(pe=p+n; p<pe; p++){
 		unpack(fld++, "d", &id);
-		*p = pushpic(o->name, id, type, o->nr);
+		*p = pushpic(o->name, id, type, nr);
 	}
 }
 
 Table table[] = {
 	{"mapobj", readmapobj, 4, &nobjp},
-	{"obj", readobj, 15, &nobj},
+	{"obj", readobj, 14, &nobj},
 	{"attack", readattack, 4, &nattack},
 	{"resource", readresource, 2, &nresource},
 	{"spawn", readspawn, -1, nil},
--- a/sce/sce.db
+++ b/sce/sce.db
@@ -5,21 +5,21 @@
 # attack: name, dmg, range, cool
 attack,fusion cutter,5,1,15
 attack,spines,5,1,22
-# obj: name, nrot, flags, w, h, hp, def, speed, vis, cost[3], time, attack[2]
-obj,scv,32,3,4,4,60,0,5,7,1,50,0,20,fusion cutter,
-obj,drone,32,1,4,4,40,0,5,7,1,50,0,20,spines,
-obj,control,1,8,16,12,1500,1,0,1,10,400,0,1800,,
-obj,hatchery,1,8,16,12,1250,1,0,1,10,300,0,1800,,
+# obj: name, flags, w, h, hp, def, speed, vis, cost[3], time, attack[2]
+obj,scv,3,4,4,60,0,5,7,1,50,0,20,fusion cutter,
+obj,drone,1,4,4,40,0,5,7,1,50,0,20,spines,
+obj,control,8,16,12,1500,1,0,1,10,400,0,1800,,
+obj,hatchery,8,16,12,1250,1,0,1,10,300,0,1800,,
 # spawn: objname, [obj..]
 spawn,control,scv
-# spr: objname, flags (PF enum), [frame..]
-spr,scv,1,0
-spr,scv,0x8001,0
-spr,control,1,0
-spr,control,0x8001,0
-spr,drone,1,0
-spr,drone,2,0,1,2,3,4
-spr,drone,0x8001,0
-spr,drone,0x8002,0,1,2,3,4
-spr,hatchery,1,0,1,2,3,3,2,1,0
-spr,hatchery,0x8001,0,0,0,0,0,0,0,0
+# spr: objname, flags (PF enum), rotations, [frame..]
+spr,scv,1,32,0
+spr,scv,0x8001,32,0
+spr,control,1,1,0
+spr,control,0x8001,1,0
+spr,drone,1,32,0
+spr,drone,2,32,0,1,2,3,4
+spr,drone,0x8001,32,0
+spr,drone,0x8002,32,0,1,2,3,4
+spr,hatchery,1,1,0,1,2,3,3,2,1,0
+spr,hatchery,0x8001,1,0,0,0,0,0,0,0,0