-/* $Id: packets.c,v 1.8 2014/06/30 18:45:31 mmondor Exp $ */
+/* $Id: packets.c,v 1.9 2014/07/14 08:26:31 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
struct spacket_torp p;
p.packet_type = SPACKET_TORP;
- p.radius = c->ship.ship->torp_radius;
+ p.radius = t->client->ship.ship->torp_radius;
p.x = BYTEORDER_NETWORK16(t->x);
p.y = BYTEORDER_NETWORK16(t->y);
-/* $Id: torp.c,v 1.7 2014/06/30 18:45:31 mmondor Exp $ */
+/* $Id: torp.c,v 1.8 2014/07/14 08:26:31 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
void
torps_update(void)
{
- torp_t *t, *next;
+ torp_t *t, *next, *t2;
int s, r, ox, oy;
for (t = (torp_t *)DLIST_TOP(&torps_list); t != NULL; t = next) {
continue;
}
+ /* Torp/torp collisions, might be expensive */
+ DLIST_FOREACH(&torps_list, t2) {
+ int tx2, ty2, tr2;
+
+ if (t2 == t)
+ continue;
+ tx2 = t2->x;
+ ty2 = t2->y;
+ tr2 = t2->client->ship.ship->torp_radius;
+ if (square_intersect(tx, ty, tr, tx2, ty2, tr2) &&
+ circle_intersect(tx, ty, tr, tx2, ty2, tr2)) {
+ collision_create(tr * tr2, tx, ty);
+ collision_create(tr * tr2, tx2, ty2);
+ torp_destroyed = 1;
+ /*
+ * XXX We should destroy t2, but this could
+ * cause a race condition, as the outer loop
+ * may still iterate through it. We thus
+ * should mark them like for clients...
+ */
+// torp_destroy(t2);
+ }
+ }
+ if (torp_destroyed) {
+ torp_destroy(t);
+ continue;
+ }
+
if (--(t->life) == 0) {
torp_destroy(t);
continue;