Day 5

So I went off on a little tangent…

I got grumpy about managing files on my computer, constantly deleting and moving folders, renaming stuff. I hate that I had to open text files to look at their contents… I kept thinking about how I was writing a ton of extra code to make saving to files work, which felt wasted because I was just going to end up moving to a database eventually anyway…

It’s eventually

That’s right, I stood up a local postgres server – for you non-techy folks, it’s just a database that will store whatever kind of data I yeet at it.

So now I have a local database server, and my code is refactored to run against that local database server… Which is actually great, because when that database gets deployed and is running out on a real server, all I have to do is change a URL. This code is permanent. Unlike the file system storage option.

Oh also, that position thing…

Well, it’s almost done. I went an extra half-mile at least. The player’s position is written to the server, and then to the database, every roughly half-second. That part is working. When the character loads in, that last known position is read from the database and handed to the client so they can move their character to the right spot when they spawn.

Excellent!

Feels like there’s a but coming

Well, yeah, obviously. I can’t get the character to actually move to the position. No matter how many times I tell it where it’s supposed to be, it just pops right back up at the origin (0, 0, 0). I think this has something to do with the fact that the server is trying to set the player’s position, but the client owns control over that particular graphic. So what I need to do is have the server let the client know where the player is supposed to be, and force the client to move the player into the right spot.

This will actually help me later when I implement protection against movehacks and wallhacks.

So that’s for tomorrow Charlie!