diff options
author | rodri <rgl@antares-labs.eu> | 2021-07-29 20:03:15 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2021-07-29 20:03:15 +0000 |
commit | b57dba67153279a84a16bba40ae007c8ae710056 (patch) | |
tree | 62ff359275ae3c70b16d341fabf59c4df1431137 /pack.c | |
parent | 3241d4b8c80f9424a3f725b5905def22916fc854 (diff) | |
download | musw-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.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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: |