Toasty's blog

SDL_net is really nice

When tinkering on a long-term project, I accumulate a lot of "demo" programs: small, simple applications that test out one thing in isolation—with the intention of merging into the main project if it feels successful.

I made one such demo using SDL_net recently. It's a very simple socket server that listens for connections and responds with a message. To be honest, I'm not used to networking when working with C/C++, and so was pleasantly surprised when it worked with ease.

It took maybe an hour and a half to get working. And it only took this long because I mistakenly followed an out-dated tutorial first, instead of going straight to the SDL_net documentation like a sensible person. Once I'd done The Right Thing, it was a breeze.

I used various tools and languages like netcat, curl, Racket and Python to check a few examples and convince myself it was working—and that I had numerous options for interaction in the future. I think this could work well.

Uses for Gealdor

Why is this useful for Gealdor? Well, players need to compose their spells and submit them to a compiler spell synthesis incantation, which checks each spell's validity and—for user convenience—should output plenty of useful notices about invalid syntax or misnamed spells, etc.

Spell writers are allowed to use computers too, though (things have moved on in the magic world). So the game will want a text editing interface.

Some people might resent the (relatively limited) text editing interface I'm capable of making. So there's some sense in at least allowing them to compose spells in a program of their choice. Allowing spells to be communicated like this also technically allows me to write the UI part in a different language, without having to bother with bindings.

For example, I could use (Dr Racket, a very extensible editor used in the Racket world, which—as you might expect—supports custom languages with relative ease). I could even use HTML and JS (probably not, though; I do enough of this already). Or I could use anything else. Another, more compelling reason to communicate input like this in general is supporting assistive technology: if the communication protocol is public, anybody can write their own interface where required.

Publishing a protocol sounds complicated, but the game already has a language for communicating spells. Building a protocol on top of this should be fairly easy.

Footnotes

  1. I'm actually considering alternative interfaces as well/instead. Text editing would be awful on a touch screen, for example, but a button interface might also be possible. We can think more about this later, though.
  2. This innocuous-seeming assumption may be my undoing.