by Shippuu Fri May 13, 2022 10:35 am
May 13
Upon reviewing the server-side code, I realized that the main block I was preparing to work on actually didn't reference the two giant "dependencies". I had believed my classes for parsing item data were deeply tied to the rest of the site, but apparently they are a remnant from an earlier iteration of the v4 build. I still need to renovate them to allow the site to have fully functional hover tooltips for items on any page except the Armory, but I can thankfully put it off until the Armory itself is fully operational again.
The main block of code is now fully adapted to the new data format, and I was also able to cut the size of the functions in half, on average. It also runs somewhere around 6-7x faster than before, too.
The last thing I need to do before I can begin on the client-side of the Armory is rebuild one more server-side piece, which I am already started on. This last piece is basically an info packet for the client-side. Instead of having to juggle around display names for sets and etc, the client just pre-loads a JSON file that has all of those already.
Separately from vaguely talking about server-side stuff to not leak details, I do want to talk about one neat optimization I made for handling equipment sets, which is saving both me and the server quite a bit of work.
On all previous iterations of the Armory, it was very clunky. The Armory had to keep a list on hand of every single item that belonged to every individual set. Then, when you equipped an item, it had to check every single set looking for which one contained that item.
If it matched a set, it incremented a counter that that set had an item equipped belonging to it. This got even more complicated with sets like Ivory or any 90+ set where multiple items could belong to the same slot of the set, so it also had to have checks to show a more generic name for that slot: "Ivory Weapon" instead of "Ivory Staff" or etc. Worse, since you can equip two rings, it also had to check for if you were equipping the same item a second time. Overall, it was just a massive hassle.
In my new approach, the Armory doesn't even keep a centralized list anymore. Each item itself now declares it belongs to a set, if any. It also declares what slot of that set it goes in. This automatically untangles all of the previous mess the Armory had to go through when equipping things. Instead of a counter, each set now has an array of integers, one for each slot.
When equipping an item, the Armory can just look at what set the item says it is, and what slot it is, then add 1 to the number at that array index. No further checking is needed. To count how many items of a set are equipped, it just checks how many array indexes within that set have a boolean value that equates to true (any value above 0). If you do something like equip two Daybreak Trailblazers, which would not complete the set, the array would have a 0 and a 2. Only one would evaluate as true, so you'd have 1/2 parts of the set, which is not enough for the set bonus.
The server is doing some other things in the background to get the names of the slots in the sets, but I will continue avoiding disclosing anything too specific about the workings of the server.