-$Id: README,v 1.1 2006/12/31 08:32:39 mmondor Exp $
+$Id: README,v 1.2 2014/06/25 12:53:13 mmondor Exp $
+
+Note that some of this text is outdated.
TODO
====
SERVER
-- Add support for collisions between torpedoes and ships.
- Add support for multiframe objects. For instance, detonations could have
multiple frames, as well as the cloaking effect. These should possibly more
be time-dependent than actual frame dependent however, considering that
- Implement authentication credentials checking, limit same user to one
connection only
- Limit connections per ip address in number and frequency
-- Implement and test using rc4 or openssl with aes. Verify if the overhead
- is negligeable enough to be worth keeping. Otherwise, we could use crypto-
- graphy for authentication only if wanted.
-- Possibly implement as part of the authentication system a method to only
- allow signed client keys, the client key would be sent to us, and then also
- make sure that only one client using that key can connect at a time,
- logging when it's not the case. This client-specific unique signed key
- could be used as ID possibly? Or other than signing we perhaps should also
- sign against the player's name and verify at login that he can only use that
- login with that key, too.
+- Implement and test using openssl with aes. Verify if the overhead
+ is negligeable enough to be worth keeping.
- Add proper connection/disconnection/events logging
CLIENT
for messages from the server using a ring, since SDL events would
automatically be queued meanwhile?
Also now send user events to the server.
-- Add an auto-ping along with fps... Use SDL_GetTicks() to calculate the
- delay between sending ping and receiving pong.
-- Create packets to also send user updates about his ship's statistics.
- These could probably be updated less frequently than 10 times per second.
NOTES
port to SDL an inter-thread messaging library I had done for use
with POSIX threads, and to use multiple threads.
-One thread will be used to send data to the server, another thread
+One thread is used to send data to the server, another thread
to receive data form the server, yet another thread to deal with
all user input events, and a main thread to receive all those events
in an asynchroneous manner form the utility threads and run the
:)
-Ogg-vorbis will be used for music, using SDL_mixer. Ship rotations
-will be performed using SDL_gfx.
+Ogg-vorbis is used for music, using SDL_mixer. Ship rotations
+are performed using SDL_gfx rotozoom.
It is very important to avoid having to link this client statically
against GPL or LGPL libraries, because of the viral nature of those
-/* $Id: main.c,v 1.6 2014/06/25 11:52:24 mmondor Exp $ */
+/* $Id: main.c,v 1.7 2014/06/25 12:53:13 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
static void send_event(int, int);
static SDL_Surface *bmp_load_key(const uint8_t *, size_t);
-static int surface_blit_angle(SDL_Surface *, int, int, int);
+static int surface_blit_angle(SDL_Surface *, int, int, int,
+ double);
static Mix_Chunk *sample_load(const uint8_t *, size_t);
static int joy_angle = 0;
-static SDL_Surface *rship, *fship;
+static SDL_Surface *rship, *fship, *ship_types[2];
static int shields = 1, cloaked = 0;
+static double ship_zoom_types[2] = { 1.5, 1.0 };
static Mix_Chunk *snd_cloak, *snd_uncloak, *snd_shield, *snd_unshield,
*snd_torp, *snd_hit, *snd_explode;
static_RomDD_bmp_enc_size);
fship = bmp_load_key(static_FedCA_bmp_enc_data,
static_FedCA_bmp_enc_size);
+ ship_types[0] = fship;
+ ship_types[1] = rship;
/*
* We're already the main thread.
}
void
-ship_draw(int id, int x, int y, int radius, double angle, uint8_t flags)
+ship_draw(int id, int type, int x, int y, int radius, double angle,
+ uint8_t flags)
{
char str[8];
- (void) surface_blit_angle(rship, x, y, angle);
+ (void) surface_blit_angle(ship_types[type], x, y, angle,
+ ship_zoom_types[type]);
if ((flags & SHIPF_CLOAK) != 0)
- filledCircleRGBA(screen_surface, x, y, 25,
+ filledCircleRGBA(screen_surface, x, y, radius,
0x00, 0x00, 0x00, 0x80);
if ((flags & SHIPF_SHIELD) != 0) {
aacircleRGBA(screen_surface, x, y, radius,
}
static int
-surface_blit_angle(SDL_Surface *s, int x, int y, int a)
+surface_blit_angle(SDL_Surface *s, int x, int y, int a, double zoom)
{
SDL_Surface *t;
SDL_Rect d;
a = (a * 360 / 256) + 90;
/* Interestingly, the angle has to be reversed... */
- if ((t = rotozoomSurface(s, -a, 1.0, 1)) != NULL) {
+ if ((t = rotozoomSurface(s, -a, zoom, 1)) != NULL) {
d = (SDL_Rect){x - (t->w / 2), y - (t->h / 2), 0, 0};
r = SDL_BlitSurface(t, NULL, screen_surface, &d);
SDL_FreeSurface(t);
-/* $Id: main.h,v 1.2 2014/06/21 17:16:32 mmondor Exp $ */
+/* $Id: main.h,v 1.3 2014/06/25 12:53:13 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
void frame_switch(void);
-void ship_draw(int, int, int, int, double, uint8_t);
+void ship_draw(int, int, int, int, int, double, uint8_t);
void torp_draw(int, int, int);
-/* $Id: packets.c,v 1.2 2014/06/21 17:16:32 mmondor Exp $ */
+/* $Id: packets.c,v 1.3 2014/06/25 12:53:13 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
{
struct spacket_ship *p = (struct spacket_ship *)ptr;
- p->id = BYTEORDER_HOST16(p->id);
p->x = BYTEORDER_HOST16(p->x);
p->y = BYTEORDER_HOST16(p->y);
- ship_draw(p->id, p->x, p->y, p->radius, p->angle, p->flags);
+ ship_draw(p->id, p->type, p->x, p->y, p->radius, p->angle, p->flags);
return 0;
}
-/* $Id: packets_common.h,v 1.3 2014/06/21 17:16:32 mmondor Exp $ */
+/* $Id: packets_common.h,v 1.4 2014/06/25 12:53:13 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
struct spacket_ship {
int8_t packet_type;
int8_t flags;
- int16_t id;
+ int8_t id;
+ int8_t type;
int16_t x, y;
uint8_t radius;
uint8_t angle;
-/* $Id: client.c,v 1.5 2014/06/22 10:24:29 mmondor Exp $ */
+/* $Id: client.c,v 1.6 2014/06/25 12:53:14 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, SHIP_CA); */
+ ship_init(&c->ship, 1 - (random() % 2)); /* XXX */
c->authenticated = c->todestroy = c->toclose = 0;
c->writepolling = 1;
-/* $Id: packets.c,v 1.3 2014/06/21 17:16:32 mmondor Exp $ */
+/* $Id: packets.c,v 1.4 2014/06/25 12:53:14 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
continue;
if (!c2->ship.cloak_on || c2 == c) {
- if (spacket_ship_send(c, (uint16_t)c2->fd,
+ if (spacket_ship_send(c, (uint8_t)c2->fd,
&c2->ship) == -1)
break;
}
}
int
-spacket_ship_send(client_t *c, uint16_t id, ship_t *s)
+spacket_ship_send(client_t *c, uint8_t id, ship_t *s)
{
struct spacket_ship p;
p.flags |= SHIPF_SHIELD;
if (s->cloak_on)
p.flags |= SHIPF_CLOAK;
- p.id = BYTEORDER_NETWORK16(id);
+ p.id = id;
+ p.type = (uint8_t)s->type;
p.x = BYTEORDER_NETWORK16(s->x);
p.y = BYTEORDER_NETWORK16(s->y);
p.radius = (uint8_t)s->ship->radius;
struct spacket_torp p;
p.packet_type = SPACKET_TORP;
- /* p.radius = c->ship.ship->torp_radius; XXX */
p.radius = c->ship.ship->torp_radius;
p.x = BYTEORDER_NETWORK16(t->x);
p.y = BYTEORDER_NETWORK16(t->y);
-/* $Id: packets.h,v 1.1 2006/12/31 08:32:40 mmondor Exp $ */
+/* $Id: packets.h,v 1.2 2014/06/25 12:53:14 mmondor Exp $ */
/*
* Copyright (c) Matthew Mondor
int spacket_auth_send(client_t *);
int spacket_pong_send(client_t *);
int spacket_eof_send(client_t *);
-int spacket_ship_send(client_t *, uint16_t, ship_t *);
+int spacket_ship_send(client_t *, uint8_t, ship_t *);
int spacket_shipinfo_send(client_t *);
int spacket_torp_send(client_t *, torp_t *);
-/* $Id: ships.c,v 1.3 2014/06/22 10:24:30 mmondor Exp $ */
+/* $Id: ships.c,v 1.4 2014/06/25 12:53:14 mmondor Exp $ */
/*
- * Copyright (c) 2006, Matthew Mondor
+ * Copyright (c) 2006, 2014, Matthew Mondor
* ALL RIGHTS RESERVED.
*/
/* XXX We need to set these to decent values */
struct shipdesc ships[SHIP_MAX] = {
{ /* CA */
- 30.0, /* Radius */
+ 35.0, /* Radius */
10.0, /* Weight */
100.0, /* Hull max */
1.0, /* Hull regen */
50.0, /* Cloak cost */
10000.0, /* Fuel max */
30.0, /* Fuel regen */
- 9.0, /* Thrust max */
+ 6.0, /* Thrust max */
0.20, /* Thrust acc */
0.30, /* Thrust dec */
5.0, /* Thrust acc cost */
5.0, /* Thrust dec cost */
6.0, /* Thrust cost */
80/*2.0*/, /* Turn thrust */
- 0.5, /* Turn cost */
+ 1.0, /* Turn cost */
200.0, /* Torp cost */
20.0, /* Torp damage */
2.0, /* Torp radius */
- 11.0, /* Torp speed */
- 60, /* Torp life */
+ 10.0, /* Torp speed */
+ 40, /* Torp life */
90.0, /* Phaser cost */
90.0, /* Phaser damage */
5.0, /* Phaser recharge */
100.0 /* Phaser radius */
},
{ /* DD */
- 40.0, /* Radius */
- 10.0, /* Weight */
- 100.0, /* Hull max */
- 1.0, /* Hull regen */
- 100.0, /* Shield max */
- 10.0, /* Shield cost */
+ 25.0, /* Radius */
+ 5.0, /* Weight */
+ 50.0, /* Hull max */
+ 2.0, /* Hull regen */
+ 50.0, /* Shield max */
+ 5.0, /* Shield cost */
3.0, /* Shield regen */
- 50.0, /* Cloak cost */
- 10000.0, /* Fuel max */
+ 25.0, /* Cloak cost */
+ 5000.0, /* Fuel max */
50.0, /* Fuel regen */
9.0, /* Thrust max */
0.60, /* Thrust acc */
2.0, /* Thrust acc cost */
2.0, /* Thrust dec cost */
1.0, /* Thrust cost */
- 1.0, /* Turn thrust */
+ 100.0, /* Turn thrust */
0.5, /* Turn cost */
90.0, /* Torp cost */
- 20.0, /* Torp damage */
+ 30.0, /* Torp damage */
3.0, /* Torp radius */
12.0, /* Torp speed */
60, /* Torp life */
d = &ships[type];
s->ship = d;
+ s->type = type;
s->hull = d->hull_max;
s->shield = d->shield_max;
s->fuel = d->fuel_max;
-/* $Id: ships.h,v 1.2 2014/06/21 17:16:32 mmondor Exp $ */
+/* $Id: ships.h,v 1.3 2014/06/25 12:53:14 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
double fuel;
double thrust, i_thrust;
double phaser_delay; /* phaser_cost - phaser_recharge */
+ int type;
int shield_on, i_shield_on;
int cloak_on, i_cloak_on;
int torps;