Okay wait, I’m getting ahead of myself.

Alright, so what I really wanted to do today was fix some stuff around saving off the user’s position. I noticed late last night that one of our characters was having their position saved appropriately, but the other one wasn’t.

A large part of that was because there was a disconnect in the code between a Character (meaning your character’s name, level, experience, stats, skills), and the graphical representation of the character that moves around on the screen.

I did a bunch of refactoring to connect those two things together. The place I was trying to force all this stuff to happen was the wrong place, but eventually, I got it so that these things are linked.

Okay but that didn’t solve the problem, I assume.

No, it didn’t But it helped me work on some other stuff I wanted to do. I needed to make it so that players could get information about other players in the area at the time of logging in. So I added that functionality too – now if Player 1 logs in, when Player 2 logs in a few minutes later, Player 2 gets some info about Player 1 and Player 1 gets some info about Player 2. This will help later when I want to add screens to support inspecting characters, and characters writing custom descriptions for themselves, etc.

Aren’t you forgetting something?

Ah, right. Yeah, in order to implement all of that, I needed to be able to log into two different characters. But that’s a problem because my client didn’t support multiple characters, it just always logged into the first character in the list. So before I could do any of that, I had to implement a really small rudimentary (and unfortunately hard-coded) login screen. I also discovered I’ll need a second server for login purposes, but that comes later. The good news is that it’s working, I can login to two different characters, and they have different positions which are now persisted!

I think you’re still forgetting something

Right, so after that I wanted to heal two birds with one potion: I wanted to implement the beginning of my character stats, and I wanted to use them to prove that I was actually logging into two different characters at the same time.

So I jumped through the hoops to add stats, and while I was doing it, I added some support for skill leveling. It was around this time that I realized fairly quickly that every time I make a change to any of these classes which will move back and forth between server and client, I have to

  • Add the property to the database
  • Change the code that reads the data from the database
  • Change the serialization extension which allows the data to move from server to client
  • Change the deserialization extension which allows the client to turn the data back into the format it wants
  • Change the actual model so that it can utilize the data

That’s so much fucking extra code, and C# has a cool thing called Reflection that allows us to automatically wire some of those things up.

You’re going to remember eventually, right?

Right, so yeah, this is when I got into a fight with ChatGPT for almost 3 hours. I’m not good enough at reflection to write this thing myself, so I asked ChatGPT for help and it actually seemed like we were really close a few times. I basically wanted it to just automatically serialize any new properties I add so that I only have to change 3 files instead of 5. I’d like to extend my sql library later to make that a little easier too. In the end it ended up being incredibly frustrating, I swore at ChatGPT a lot, and then I gave up.

OKAY BUT WHAT ABOUT THE POSITION THING? LITERALLY THE FIRST THING YOU SET OUT TO DO TONIGHT????

Oh yeah I eventually discovered that I had the character id hard-coded in the position update, so no matter which character tried to update, it was just updating the one I’d hard-coded.

Whoops!