aboutsummaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2021-07-29 20:03:15 +0000
committerrodri <rgl@antares-labs.eu>2021-07-29 20:03:15 +0000
commitb57dba67153279a84a16bba40ae007c8ae710056 (patch)
tree62ff359275ae3c70b16d341fabf59c4df1431137 /pack.c
parent3241d4b8c80f9424a3f725b5905def22916fc854 (diff)
downloadmusw-b57dba67153279a84a16bba40ae007c8ae710056.tar.gz
musw-b57dba67153279a84a16bba40ae007c8ae710056.tar.bz2
musw-b57dba67153279a84a16bba40ae007c8ae710056.zip
incorporated libgeometry into the project.
transitioned the integrator from scalar to vector-based. added a packing procedure for Point2. created the structure to model bullets.
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/pack.c b/pack.c
index a1335c2..50d72f1 100644
--- a/pack.c
+++ b/pack.c
@@ -1,6 +1,7 @@
#include <u.h>
#include <libc.h>
-#include <draw.h> /* because of dat.h */
+#include <draw.h>
+#include "libgeometry/geometry.h"
#include "dat.h"
#include "fns.h"
@@ -21,6 +22,7 @@ vpack(uchar *p, int n, char *fmt, va_list a)
{
uchar *p0 = p, *e = p+n;
FPdbleword d;
+ Point2 P;
for(;;){
switch(*fmt++){
@@ -36,6 +38,14 @@ vpack(uchar *p, int n, char *fmt, va_list a)
put4(p, d.lo), p += 4;
break;
+ case 'P':
+ P = va_arg(a, Point2);
+
+ if(p+3*8 > e)
+ goto err;
+
+ pack(p, n, "ddd", P.x, P.y, P.w), p += 3*8;
+ break;
}
}
err:
@@ -47,6 +57,7 @@ vunpack(uchar *p, int n, char *fmt, va_list a)
{
uchar *p0 = p, *e = p+n;
FPdbleword d;
+ Point2 P;
for(;;){
switch(*fmt++){
@@ -61,6 +72,12 @@ vunpack(uchar *p, int n, char *fmt, va_list a)
*va_arg(a, double*) = d.x;
break;
+ case 'P':
+ if(p+3*8 > e)
+ goto err;
+
+ unpack(p, n, "ddd", &P.x, &P.y, &P.w), p += 3*8;
+ *va_arg(a, Point2*) = P;
}
}
err: