-/* $Id: client.c,v 1.7 2014/06/30 18:45:31 mmondor Exp $ */
+/* $Id: client.c,v 1.8 2014/07/01 11:12:51 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
recvq_reset(&c->recvq, c);
(void) memcpy(&c->saddr, saddr, sizeof(struct sockaddr));
- /* ship_init(&c->ship, SHIP_CA); */
- ship_init(&c->ship, 1 - (random() % 2)); /* XXX */
+ ship_init(&c->ship);
c->authenticated = c->todestroy = c->toclose = 0;
c->writepolling = 1;
-/* $Id: ships.c,v 1.8 2014/06/30 03:37:35 mmondor Exp $ */
+/* $Id: ships.c,v 1.9 2014/07/01 11:12:51 mmondor Exp $ */
/*
* Copyright (c) 2006, 2014, Matthew Mondor
+/* Random ship, position and angle for now. */
void
ship_reset(ship_t *s)
{
- struct shipdesc *d = &ships[s->type];
+ int type = random() % SHIP_MAX;
+ struct shipdesc *d = &ships[type];
+
+ s->ship = d;
+ s->type = type;
s->hull = d->hull_max;
s->shield = d->shield_max;
s->shield_on = s->i_shield_on = 1;
s->cloak_on = s->i_cloak_on = 0;
- /*
- * XXX Random position/angle for now.
- * Should also at least not place the ship on top of another one...
- */
+ /* XXX Might land on another ship and immediately explode */
s->angle = s->i_angle = (random() % 255);
s->x = d->radius + (random() % (int)(WORLD_X_MAX - (d->radius * 2) - 1));
s->y = d->radius + (random() % (int)(WORLD_Y_MAX - (d->radius * 2) - 1));
}
void
-ship_init(ship_t *s, int type)
+ship_init(ship_t *s)
{
- struct shipdesc *d;
- DEBUG_ASSERT(s != NULL);
- DEBUG_ASSERT(type > -1 && type < SHIP_MAX);
-
- d = &ships[type];
-
- s->ship = d;
- s->type = type;
s->torps = 0;
ship_reset(s);
}
-/* $Id: ships.h,v 1.4 2014/06/25 15:05:47 mmondor Exp $ */
+/* $Id: ships.h,v 1.5 2014/07/01 11:12:51 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
-void ship_init(ship_t *, int);
+void ship_init(ship_t *);
void ship_update(ship_t *);
void ship_reset(ship_t *);
int ship_hit_torp(ship_t *, shipdesc_t *);