Tuesday, July 23, 2024

Sometimes you do the same thing really well. Twice.

And each time, you do it for the first time.

So, lets start with some back story here. While I was doing all the recent changes to the code in the way that static files are served to the app, I found a few things to be true. Firstly, the data sent was much larger than I thought it was. But that's not the important part, just leads to it. Anyhow, when the app gets new terrain information, it updates the min and max x and y coordinates of what it has, so that it can go and request more when it approaches the end. As I was working on creating the data files to server to the app, I saw the error in that code, and sadly worked out that while it worked in an ideal world, it would be very easy to have a "gap" in the map between the min and max coordinates, but with a blank bit. Sort of like a hole in the centre of a sheet of paper. Then what would happen, it wouldn't request more terrain, but it wouldn't have terrain to display.

So, the solution I came up with was that it would request new terrain each time the party moved a certain number distance in any direction. When it did that, it would take a note that it had asked for that location, and then if it got there again, it knew it had it, so no more requesting it. Great, that's the app covered, but I should put that same functionality into the editor I use to create the game world right? I can get rid of a bunch of other database entries (even longer, unnecessary story there). Getting rid of those entries would make the data chunks sent to the app smaller. Everyone's happy.

So I open up the editor code, start working backwards in the code from a particular action to try to find the point in the code where the trigger lies that causes more map to be loaded. Hey presto. It checks to see if you've moved a certain distance in any direction, and once you get past it, it will fetch more data from the server.

Just like the app does. Now that I updated it.

At least I know that I got to a nice elegant solution twice, apparently each time thinking it was the first time I'd done it.

No comments:

Post a Comment

Stabilising and Bugfixing

There's been a good bunch of things in the app, that I've known about, known that were broken or unfinished, but I've simply bee...