|
|
@ -248,6 +248,16 @@ void des_float(char **in, float *f)
|
|
|
|
memread(in, f);
|
|
|
|
memread(in, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ser_double(char **out, double d)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
memwrite(out, d);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void des_double(char **in, double *d)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
memread(in, d);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ser_int(char **out, int i)
|
|
|
|
void ser_int(char **out, int i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
memwrite(out, i);
|
|
|
|
memwrite(out, i);
|
|
|
@ -393,10 +403,11 @@ void into_bytes(struct ServerToClient *msg, char *bytes, int *out_len, int max_l
|
|
|
|
ser_int(&bytes, msg->your_player);
|
|
|
|
ser_int(&bytes, msg->your_player);
|
|
|
|
LEN_CHECK();
|
|
|
|
LEN_CHECK();
|
|
|
|
|
|
|
|
|
|
|
|
ser_float(&bytes, gs->time);
|
|
|
|
ser_double(&bytes, gs->time);
|
|
|
|
LEN_CHECK();
|
|
|
|
LEN_CHECK();
|
|
|
|
|
|
|
|
|
|
|
|
ser_V2(&bytes, gs->goldpos);
|
|
|
|
ser_V2(&bytes, gs->goldpos);
|
|
|
|
|
|
|
|
LEN_CHECK();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (int i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -433,7 +444,7 @@ void from_bytes(struct ServerToClient *msg, char *bytes, int max_len)
|
|
|
|
des_int(&bytes, &msg->your_player);
|
|
|
|
des_int(&bytes, &msg->your_player);
|
|
|
|
LEN_CHECK();
|
|
|
|
LEN_CHECK();
|
|
|
|
|
|
|
|
|
|
|
|
des_float(&bytes, &gs->time);
|
|
|
|
des_double(&bytes, &gs->time);
|
|
|
|
LEN_CHECK();
|
|
|
|
LEN_CHECK();
|
|
|
|
|
|
|
|
|
|
|
|
des_V2(&bytes, &gs->goldpos);
|
|
|
|
des_V2(&bytes, &gs->goldpos);
|
|
|
@ -494,6 +505,7 @@ struct Grid *closest_to_point_in_radius(struct GameState *gs, V2 point, float ra
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// for random generation
|
|
|
|
static float hash11(float p)
|
|
|
|
static float hash11(float p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p = fract(p * .1031);
|
|
|
|
p = fract(p * .1031);
|
|
|
@ -502,6 +514,11 @@ static float hash11(float p)
|
|
|
|
return fract(p);
|
|
|
|
return fract(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t tick(struct GameState *gs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (uint64_t)floor(gs->time / ((double)TIMESTEP));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void process(struct GameState *gs, float dt)
|
|
|
|
void process(struct GameState *gs, float dt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(gs->space != NULL);
|
|
|
|
assert(gs->space != NULL);
|
|
|
|