Initial work on connecting clients over UDP.

This commit is contained in:
2023-07-02 23:08:59 +01:00
parent a6d27ecfa4
commit 56c1332675
4 changed files with 81 additions and 8 deletions

View File

@ -1,4 +1,21 @@
#include "cspt-state.h"
void updateInput(struct gameState * state, struct clientInput * message, struct sockaddr_in * address, int * clientSockets)
{
int index = 0;
struct sockaddr_in currentClientAddress;
for (index = 0; index < 16; index++)
{
getsockname(clientSockets[index], (struct sockaddr *)&currentClientAddress, (socklen_t *)sizeof(struct sockaddr_in));
if (currentClientAddress.sin_addr.s_addr == address->sin_addr.s_addr)
{
state->clients[index].leftAcceleration = message->left;
state->clients[index].rightAcceleration = message->right;
state->clients[index].upAcceleration = message->up;
state->clients[index].downAcceleration = message->down;
break;
}
}
}
void doGameTick(struct gameState * state)
{