From b57dba67153279a84a16bba40ae007c8ae710056 Mon Sep 17 00:00:00 2001 From: rodri Date: Thu, 29 Jul 2021 20:03:15 +0000 Subject: 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. --- pack.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'pack.c') diff --git a/pack.c b/pack.c index a1335c2..50d72f1 100644 --- a/pack.c +++ b/pack.c @@ -1,6 +1,7 @@ #include #include -#include /* because of dat.h */ +#include +#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++){ @@ -35,6 +37,14 @@ vpack(uchar *p, int n, char *fmt, va_list a) put4(p, d.hi), p += 4; 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; } } @@ -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: -- cgit v1.2.3