Monday, March 31, 2014

The IRC Connection Handshake

This isn't really documented anywhere, so I suppose I'll take a moment to write it down.

IRC is a fairly simple text-based protocol that manages interactions between servers and clients. Messages are made of either a command or server message code followed by arguments and optionally some trailing data.

So, a message from a server to a client might look like this:
:irc.some.net 999 arg moreArgs :Trailing data counted as one arg

A message from a server indicating that a client did something interesting might look like this:
:person!usrId@host.isp.net PART #chan :Goodbye everyone!

The most difficult part of creating an IRC program is getting the handshake right. To start, the first command you need to send is user. This identifies your session name and will fill the "real name" field on a who-is query.
USER sessionId irc.some.net irc.some.net :Real name

It's not really specified what to put in the two middle fields, but I find it works to just put the IP or hostname of the server you connected to. Once that's done, send a NICK command, which will set the name you use to talk to people.
NICK UncreativePersonName

If all goes well, you should receive a ping message from the server with some random letters and numbers in the trail. Send a pong back with those same characters, and you're in!
Server: PING :10A45D9F
Client: PONG :10A45D9F

There will be ping messages later in the connection that have a server name in the trail, but just put whatever trail is given to you back into the pong.

Once the server checks the pong, you'll receive an 001 (welcome) message, probably followed by all kinds of stuff, MOTD and other info. Keep replying to pongs, and you can have a stable IRC robot!

Sunday, March 30, 2014

NKStat

Those in the Commander Keen community have probably heard of NetKeen, the Keen 5-based multiplayer race/battle created by a user named Lemm. It's still played quite frequently. Something I've imagined is a way of keeping track of NetKeen games and players, like the USCF does with chess. I kind of tried something with WinBot a few years ago, but that program is really not well suited to something like this.

So, armed with Visual Studio and knowledge of low-level IRC protocols, I started messing around today with getting an IRC robot going. I was quite successful; in just a few hours I had a bot that could survive ping requests, join channels, and hear users talk. It's a long way away from actually managing ratings and stuff like that, but it's definitely a start. Hopefully, this will be pretty easy.

Saturday, March 29, 2014

FMod - Custom Tile Property List

I'm just about ready to release v1.3.1 of Abiathar; all that remains to fix is the documentation and a very strange GUI bug that causes the "Signature" label to never appear next to the appropriate text box.

One of the important things this update will do is add the ability to add custom entries to the Tile Property Modifier's drop-down lists. This is accomplished with some optional entries in a profile structure in the persist.aconf XML file. I'm considering moving them to somewhere else (like in the local config) or making it fully customizable (so the entire list is stored on disk somewhere), but this works for now and isn't really a high-use feature.

Friday, March 28, 2014

FMod - Better Find

One of the very few bad things about Abiathar was its "find" tool, the Tile Instance Locator. Before today, it would move the view window while searching to indicate where it found the tiles, which (in addition to being incredibly disorienting and inconvenient) did not work at all when bounded scrolling was enabled in the config file. So, I took a moment today to make it considerably less awful. It now works similarly to other editors' tile search mode, highlighting every instance of the selected combination of tiles. I wired it up to the plane state change event so it automatically recalculates the counts and rerenders the highlights when necessary.

I also adjusted the plane state menu items to make the consistent with the mode labels and added a nice "Help" menu with some links to various places where it might be possible to get help with Abiathar.

Thursday, March 27, 2014

FMod - Animation Cycles are Hard

With Abiathar development slowing down (I'm running out of features to add!), I took a moment today to look at Shock Tile, the Keen:Galaxy tileset packer that I kinda-sorta abandoned a month or so ago. I went back to it today because I had corrected a huge bug in FleexCore that was switching the values of the animation offset and animation delay.

I had hoped to open the Visual Studio project, recopy the default game files, run the program, and see it work perfectly. That was not the case: it crashed with a very similar problem to what it had before. It is genuinely awful that some tiles animate in non-cyclical patterns and have tiles part way through the path appear before tiles at the beginning of the path. Basically, to make this work and not wreck all the animations, it needs to check every single tile to see if anything animates to it and then place one very close to the other.

Wednesday, March 26, 2014

FMod - v1.3

Well, it doesn't have as many changes as I had planned, but Abiathar v1.3 is here! This makes Abiathar possibly the first "smart" Galaxy editor. The Level Inspector and inspection mode of the Tile Property Modifier can warn about all kinds of problems without even needing to load the game. The Resource Accountant can count up (as one might imagine) all the resources available to players in the level. It even is customizable and ships with tweaks for NetKeen.

I also fixed the following bugs:

  • Tile Property Modifier sets all animating or solid tiles to be foreground
  • TPM animation target overlay remains after the tool is canceled
  • Row/Column Adjuster nulls the level name when used
  • Single-level files can't be loaded
Abiathar is by far the most amazing level editor for Commander Keen.

Tuesday, March 25, 2014

DOS Source Released

Microsoft just made the source code for DOS versions 1.1 and 2.0 available for public viewing. The repository is composed of quite a few assembler files with some text files containing notes and format specifications. I don't personally understand assembler very well, but I'm sure there are those who would like to see how DOS works. This is really the source Microsoft used; it's decently-commented and everything.

Link to the download page at Computer History Museum

Monday, March 24, 2014

FMod - Metafile Maybe

With my upcoming additions to Abiathar in mind (like custom non-EGA infoplane overlays), I will probably need a better place to store them than the dependency files. They have been amazing for Abiathar use so far, but they are just text files and would be terrible to use as partial binary, partial config file.

Therefore, I think I am moving to a new format for managing Abiathar projects. I'll give it the aproj extension, and it will contain non-human-readable stuff. Config will be in there too, but editable in Abiathar GUI.

I really don't know, to be honest. I suppose I'll see where coding takes me...

Saturday, March 22, 2014

FMod - Inspectors

When I spend time making a level, compile it, and run it in the game only to find that it causes a crash, I am very sad. I'm sure this makes other people very sad as well. Therefore, to solve the problem of depression, I am adding inspectors to Abiathar that will examine resources and spit out a list of issues that may cause bad things to happen if they are loaded into the game.

Yesterday, I added an inspection mode to the Tile Property Modifier. When the user presses the I key, it will, starting at the beginning of the tileset, find the first tileinfo-related problem and ask to display the offending tile's properties in the dialog. The user can choose to deal with the issue, continue the inspection, or cancel the inspection. When the end of the tileset is reached without issue, it displays a very affirming dialog box. The TPM inspection mode looks for broken animation loops, animations to null tiles, animations to outside the tileset, and animation collisions.

Today, I started a Level Inspector tool that will share a lot of internal processing with an upcoming resource counting tool. It will check for issues with level size, scroll blocks, animation collisions, sprite memory usage, and tile cache. To make it (and the upcoming counter tool) work, I need a Mindbelt-esque script file to define what the various infoplane tiles do. I have worked out a somewhat complicated system for managing that, but I still need to write the default config entries.

Thursday, March 20, 2014

FMod - v1.2.3

There is a never-ending stream of amazing ideas I'd like to implement in Abiathar. But first, I need to clear the bug queue and ensure that everything is working as expected. Today, I actually pushed the update that fixed the Freeform Tile Placer's single-tile overlay. I also figured out how to implement the smear paste mode that one of the testers had requested, so that made it into v1.2.2. Just a couple hours after releasing that, I discovered a really strange bug in the Tile Property Modifier that caused it to regenerate its detached window after it was canceled. There was also a small problem in the tile palette switching code that failed to notify the tools of the change (but worked with graphics correctly). v1.2.3 was pushed as soon as I got the repairs together.

Wednesday, March 19, 2014

FMod - v1.2

This spring break certainly has allowed me to do a lot on Abiathar. Today, I tackled yet another of Ceilick's batches of requests and bug reports. This time, there weren't any huge revamps to be done, just some tweaks and minor stretchings of existing infrastructure.

Four bugs were reported, one of which was not actually a bug (documentation, it is good to read) and one of which only required changing a default setting (it was a good change though). I made a small adjustment to the Freeform Tile Placer to allow it to start placing tiles with a mouse click, not just a mouse drag. The last bug in this set was a rendering error with the tile palette; I had forgotten to erase the drawing surface before rendering new properties from the Paster.

Six improvements were suggested, one of which was already in the program (again, the documentation, please read it). All but one of the remaining five were fairly simple; the difficult one (which never did actually make it into the update) was the ability to drag the Paster to easily smear the stamp all over the level. I did, however, improve the Paster by giving it a keyboard toggle in and out of non-zero-only mode and reassigning the right mouse button to a new eraser function. NetKeen editing has been made better by the addition of the level signature modifier in the level properties window. The Tile Property Modifier has been made a viable tileinfo tool with some re-imagining of the relationship between dialog boxes. Finally, the most difficult feature that I did implement was bounded scrolling: locking the viewport inside the level and having the scroll wheel automatically change direction upon hitting an edge. It was genuinely more challenging than adding tileinfo support, but I did get it done.

With the update pushed, I went into the #KeenModding IRC channel to see what people were saying about it. Ceilick arrived eventually, with even more glitches to fix. I had somehow broken the single-tile overlays and there were a few GUI errors concerning other visual effects. I pushed v1.2.1, which fixed those and also added some minor features like right-mouse-dragging to the Freeform Tile Placer.

In other news, the Abiathar release thread is stickied in the Galaxy Level Editors section of the Keen Modding forum - I guess that means it's the officially endorsed editor!

Monday, March 17, 2014

FMod - v1.1

Today, I set out to finish the first major addition to Abiathar since its public release: the tileinfo editor. I figured out a very effective (and enterprisey) method of updating all the tileinfo overlay instances when a property is changed. When the Tile Property Modifier tool changes a tile, it will send a NotifyTileinfoChange message through its state accessor to Abiathar Core, which will then raise MarkDirty on all planes that report HasTileinfo for that plane.

Armed with that working, it was trivial to put in other nice features like property copying and animation linking. There was in issue involving the animation target highlight on background tiles, but that was fixed by checking which tileinfo helper was being used. (Also, it's kind of a pain that the ComboBox control in DropDownList mode won't let you just set the SelectedText property, but that was an entirely different bug.) After some more testing, I decided it was release-ready.

Documentation is important, so I updated the appropriate sections, also updating screenshots of GUIs that had been changed. With the new help file uploaded, the update files in place, and testing done, I flipped the switch on the update (and wrote a little post about it on the PCKF thread). It met with great success, but just a few hours after the release, I myself noticed a horrifying bug: if a gamemaps file was loaded that did not have a level in slot 0, Abiathar would erase all the levels. I fixed it very quickly (and also put in the code for the Instant Carma reverser I'd been working on) and reuploaded it as v1.1.1.

Sunday, March 16, 2014

FMod - Tile Property Editor

Though I hadn't originally planned to, I think I might go ahead and try to make Abiathar into a full Keen Galaxy modding studio. For this next update (v1.1), I'm just focusing on getting a tile property editor working.

First, I had to redo a lot of the IO code and the Dependency Collector. I now have a somewhat complicated system of tileinfo storage profiles, each of which has a letter ID, which is placed before the tileinfo file's path in the dependency file. Instead of just a "from memory" check box, there is now a drop-down in the tileinfo section of the DC. Some of the options there include:
  • No tileinfo file
  • From memory
  • In maphead
  • In separate file
There are a few more to combine and convert between them, but those are the main things I wanted to accomplish. I was also careful to maintain compatibility with the old style, using that nice versioning system I put in yesterday.

The actual modification of tileinfo is done with a tileset tool: the Tile Property Modifier. It needs three things: an animation linker, a property stamp (copy/paste), and of course the individual tile modifier. I have that last one working, but it doesn't currently update the tileinfo overlay. That will require a little bit of work on cache removal tomorrow, but it should be easily possible.

Saturday, March 15, 2014

FMod - Just the Beginning

Yesterday, I released Abiathar publicly. However, this is not the end of the road. In fact, it is just the beginning of a (probably) long path of updates, each adding amazing new features as the community's level makers become more advanced. In fact, just today I started on some important changes.

First, I added a better versioning system to the dependency files. It will help me keep track of what future versions support what features and ensure that old versions don't try to open (and thereby butcher) new versions' files. That was accomplished with a small module containing an array of structs, one for each version information thing, and a few helper methods.

I went through the help file PDF and discovered a few proofreading errors, which I corrected and re-uploaded.

More interestingly, I made the infoplane special values more accessible. There is now a very nice interface with some text and drop-downs explaining what these values do.

Finally, I'm adding a little bit more code to the FleexCore stuff to allow storage of maphead and tileinfo in the same file. Then, ManTliMh will be unnecessary and there will be fewer resources to worry about.

Friday, March 14, 2014

Abiathar Release!

Today marks a huge milestone in the development of Abiathar! This day, March 14, internationally recognized as Keen Day, I released the official one-point-oh to the community. It has been received with many good words, it seems everyone is excited!

Early this morning, I changed the content of the newest-version file in my Dropbox from whatever pre-release version it was to "v1.0" and pasted my very length introduction message into a new PCKF post. Already, some super-awesome modders praised it with glowing words. This is a huge success!

View the PCKF topic and download Abiathar!

This is not the end of the road, though. I have plans to expand it with all kinds of awesome stuff, like analysis tools and a patch file generator. For now though, I'll rest and be content with my work so far.

Vandalizing the Keen 6 world map

Thursday, March 13, 2014

Revitalizing the Beowulf RPG

Last semester, I made a SupaChat Server snap-in that manages an RPG somewhat related to Beowulf. Its presentation was not as spectacular as I had hoped; the extreme WiFi lag caused a lot of dropped connections. Since the teacher wants us to play it again in class tomorrow (we have a free end-of-quarter day), I tried to fix it up today.

First, there were a few issues left over from the move to SCS2. Namely, it parsed messages totally wrong and couldn't understand when people left the game. Most of the bugs were pretty easy to fix, but one required a change to the server application - I forgot to inform services of the full user ID of a joining user!

Since this all happened on very short notice, I didn't add any more features to the game. I did test pretty much everything, and it works, so that's good. The thread safety I applied to the server should help quite a bit with stability. Hopefully, everything will go well!

Wednesday, March 12, 2014

FMod - Deployment Time

Two days to the big day. On March 14, I will deploy Abiathar publicly, probably shocking the Commander Keen modding scene. I thought I was done with all the work, but there was actually quite a bit I did tonight:

  • Tweaked the tileinfo renderer, it now shows pole tiles as well
  • Linked Interop.dll to the resources to work with the File Emitter
  • Prepared a very lengthy release post
  • Threw together an ILMerge setup for people to compact the assemblies if they want
  • Tweaked the help file to document the CopyLocalCfg element
  • Took some amazing screenshots for posting
  • Cleaned up and prepared the deploy directory
On Friday, all I have to do is change the contents of one text file in my Dropbox, powering on the update checker for the official 1.0 release. I'll copy-paste my Very Lengthy Release Speech into the submission box, and everyone will love it! (At least, that's the plan.)

Wow, this will be my first big deployment. So excited!

Monday, March 10, 2014

FMod - Slightly More Extensible Config

I determined that my previous strategy of having normal defaults in the general config file be copied to the local config was implemented poorly. The way I was doing it, I needed to have a separate instruction for each piece of information that needed to be copied. If I needed to add one, I would have to add at least three lines of code.

So, I changed how default config for profiles is stored. There is now one entry that contains a list of paths for the local config file and their default values. It looks something like this:

Core/InfoplaneTileCount=72;Core/MapEdge=76;Core/EnablePaths=False

Basically, it's paris of ConfigHelper paths and values, separated by semicolons. This works very well and is extensible - just add any entry to the profile config and it will be copied to the local config, no questions asked.

Sunday, March 9, 2014

FMod - Documentation and Tweaks

5 days until Abiathar's release!

Today, while neglecting taking a break from my homework, I wrote the rest of the user documentation for Abiathar and compiled it into a Word document, from which I might create a PDF. The documentation mentions pretty much everything I know about Abiathar, which was the goal. I still need to create a reference for the extension API, but that's not critical to the release this Friday.

I also executed some other tiny changes to make sure everything's right:

  • Allowed the non-focused pane in Simultaneous Tileset mode to receive keystrokes that the active pane didn't handle
  • Fixed the default map edge values
  • Fixed a selection rectangle glitch when switching levels with the Tile Instance Remapper
Finally, I created a little utility to manage NetKeen's combined tileinfo/maphead files. It's in the File Emitter and is documented in the Advanced Use section of the help.

Thursday, March 6, 2014

FMod - Extensible Profiles

While sitting in biology class listening to the teacher talk about citing in APA format (which I already knew how to do), I remembered that I had never tried to use Abiathar on NetKeen levels. NetKeen is a fan-made hack of Keen 5 that allows an in-game duel over TCP/IP, using slightly changed formats of everything.

Loading its stuff failed miserably (because of slight differences in layout, especially in the graphics), so I started adding a "Netkeen" option to the Dependency Gatherer. However, there are so many versions and sub-episodes of Netkeen that it became really awful to try and support them all. In fact, I never did get it working.

Instead, I went to implement a totally re-designed method of storing which episode the levels are from. Now, the config file stores all kinds of information about the possible episodes, which I'm now calling "profiles" because you can have multiple config sets for each game. The Dependency Collector uses it, the IO code was tweaked to support it, and a few helper methods were added or changed to include this new feature!

Wednesday, March 5, 2014

FMod - Object Oriented Tools

As I added tools and features to Abiathar, I added more and more members for the tool interface. For each little line in the interface definition, at least three were required in every existing tool - even if that features was not used in the tool. So today, I decided to go through the tool classes and re-work them to all subclass one "guard class" that would implement all the necessary things and let the tools override only the methods necessary for them to function. I also integrated the area highlighting/previewing overlay placement logic into the superclass so it didn't have to copy/pasted all over the place. This new layout will be very helpful if I have to add more things tools can do. (Also helps with file size!)

Monday, March 3, 2014

Restricted Interfaces, Please

In Abiathar's extension API, there are two or three interfaces that would mess everything up if implemented by something other than Abiathar Core. They need to be interfaces because I don't want the extensions to need a reference to Abiathar's internal details, which may change drastically. It wouldn't really be a problem unless objects of the interface types didn't have to be passed back through the API, which they do. (Level wrappers.)

Also, in F#, Clojure, and (maybe) Haskell, there is an Option type that may or may not be an instance of Some, which contains a real value. Option is also subclassed by None, which is kind of the entire point of being an option type. Now, it's possible to inherit Option with some other class that breaks all the logic. This can't be stopped because Option has to be inheritable by Some and None to have an option.

What I really want is some way to restrict which assemblies can implement an interface or inherit a type. I at first thought adding a line like "InheritableBy etc" to the definition would work to allow only those types to inherit it, but this significantly increases compiler/parser complexity. Also, it would be difficult to make it not break when used in different assemblies (would a reference to the original be needed? that would defeat the purpose).

Sunday, March 2, 2014

FMod - Overlays Everywhere

With less than two weeks left before the release of Abiathar, I need to get my act together and have absolutely zero bugs when I go public. During yet another feature-requiring conversation with a very important tester, I learned about a few inconveniences when working with the simultaneous tileset. That session also prompted me to actually implement the fancy translucent selection rectangles when appropriate tools are being used. I added preview and selection overlays to all the following tools: tile tweaker, freeform tile placer, rectangle filler, circle filler, copier, and palette copier. They added a fair amount of complexity and code copy-paste to the tools, but I think they're worth it. They even have configurable settings, which can be set in the newly-fixed (it previously liked to get saved in the resources folder) persistent options file.