From dcccf78b045a400bc31b48d09a20f684dcc320ab Mon Sep 17 00:00:00 2001 From: Barry Kane Date: Sun, 9 Jul 2023 01:30:58 +0100 Subject: [PATCH] Fixed minor oversight (updating input on client-side) --- README.org | 5 +++++ src/client/cspt-client.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 2db6212..dea5be8 100644 --- a/README.org +++ b/README.org @@ -44,6 +44,11 @@ side prediction described in the second article. I'd imagine there's still a lot more to deal with, but we'll see how much of a difference this makes to how it feels. I'll report back. +** Entry 04: Whoops, little oversight! +I didn't make the client update it's own input in the state constantly, so there +wasn't the required "single-player" feeling in the client. Not exactly what +we're going for, here! + * Notes On Techniques: ** Entry 00: Where I'm Learning All This From: I'm using a series of articles from gabrielgambetta.com, which seem to be well diff --git a/src/client/cspt-client.c b/src/client/cspt-client.c index 02f89e1..664ac6c 100644 --- a/src/client/cspt-client.c +++ b/src/client/cspt-client.c @@ -91,11 +91,13 @@ void * networkHandler(void * parameters) } } -void * gameThreadHandler(void * arguments) +void * gameThreadHandler(void * parameters) { + struct threadParameters * arguments = parameters; while (true) { - doGameTick(arguments); + updateInput(arguments->state, arguments->message); + doGameTick(arguments->state); usleep(15625); } } @@ -258,7 +260,7 @@ int main(int argc, char ** argv) parameters.message = clientInput; parameters.state = currentState; pthread_create(&graphicsThread, NULL, graphicsThreadHandler, ¶meters); - pthread_create(&gameThread, NULL, gameThreadHandler, currentState); + pthread_create(&gameThread, NULL, gameThreadHandler, ¶meters); pthread_create(&networkThread, NULL, networkHandler, ¶meters); while (continueRunning)