2
skiilaa
7y

!rant

So I decided to collab with a website's maker (who i wont name here) to create something like r/place. (not an exact copy.)

I decided to start by learning their API, and customizing the server later.

I asked the guy for some help, and HOLY SHIT.

Let's start off by this: I had to request a chunk. The response data was in binary. 4 bits meant 1 pixel, so right away, I had to deal with that in my code.

No problem, just decided to use C# instead of JS. (see https://www.devrant.io/rants/547013)

I was finally done after a couple of mental breakdowns, and decided to implement updates.

I needed to use webhooks, and that was completely fine. But when I got "C1FFFF0000CA06" as response (in hex), I seeked some help.

C1 is the operation type: it means that a pixel was updated.

FFFF and 0000 were the chunk coordinates. But remeber: it's a signed integer. Guess what, I had to use Two's compliment. I decided to be a lazy asshole and only check for "00000000" because I was only displaying chunk 0,0.

CA06: This is a weird one. It's 2 bytes, and CA0 contains the X and Y coordinate of the pixel (in the chunk), and 6 contains the new color of the pixel.

I was sent the following code to work with 0xCA06:

color = 0xF & buffer
x = buffer >> 10
y = (buffer >> 4) & 0x3F

So I tried to do it, and it didn't work. I'm not blaming the developer of the server (original dev is reddit) because maybe I screwed up, but which guy will have a night of frustration and debugging?

Me.

P.S.: Dev, if you see this, I'm sorry. This API is way too complicated. I know we need to save bandwith and stuff, but damn.

Comments
  • 1
    Nope, nope and nope.
    Step 1. Replace that piece of shit API
Add Comment