Yearly Archives: 2009

Generating Maps

Generating maps on Basternae 2 was a bit of a pain.  It was done with about 1000 lines of hacked-together C code that I wrote that read in an ASCII file, asked you the dimensions and map type (surface, underdark, etc), and then brute-forced it into a simple zone file.  It was not elegant, but it worked, usually.  Unless, of course, you entered a wrong number, had an extra character on one line, or anything like that.

The surface map I showed yesterday is just an enlarged 120 x 50 bitmap.  I only used 9 colors when creating it — one for each terrain type.  There is no accompanying ASCII text file.

It’s entirely possible with a lot of grunting and swearing that I could convert it into an ASCII file which I could then import into that old C program.  Why bother?  There has to be a better way.  Turns out there is.

Last night I created a small application that does one thing and only one thing — generates maps for Basternae.

Here’s how it works:

1. Load in a bitmap of any size.
2. Select a menu item and the program analyzes the bitmap and generates a list of all the different colors used in it.
3. Use that list to generate a room template for each color — title, description, and terrain type.
4. Let the user edit the list of templates so you can say light green is “The Forest of Evil” and dark green is “Drachenwald Forest”.
5. Select another menu item to have the program use the template file as it goes through the image pixel by pixel and generates a room for each pixel.

The obligatory screenshot:

Basternae map generator screenshot.

I’m a bit surprised that it only took a couple hours to write.  It’s the sort of thing that the serialization, bitmap, list, and datagrid classes built into .NET make very easy to do.

It is missing one major thing — it doesn’t connect the rooms together via exits yet.  That will be easy enough to add (probably about an hour to do).  It does, however, generate a zone that loads into the editor and can be tweaked and refined further.

There’s also one neat thing about the design — the room templates can be saved off to a file and loaded again, so you don’t have to edit it all in one sitting, risk losing your work if the power goes out, and can use the same room definitions with different image variations (provided you used the same colors).

Basternae 3 Surface Map

I have a few goals with the Basternae 3 surface map:

1. Has to be fairly small. No epic 90,000-room maps that take half an hour to get to the next zone.
2. Has to have both raidable and non-raidable sections. The raidable sections should be easy to get to for both sides. The non-raidable sections should be more-or-less “safe”.
3. Should be contiguous — no randomly-spaced islands, be they large or small.

In short — I want it to be small enough that the world doesn’t feel empty when there are only a few people on, but large enough to have room a good number of zones, and for people to chase each other around a bit.  If there is an error to be made in sizing I’d prefer to err on the side of too small.

Here’s what I’ve come up with. It’s subject to modification, of course, but it captures the general idea:

Basternae Surface Map

It will be a while before it’s in the game, so it may evolve. There will also be cavern (underdark) map at some point.

Small Client Update

I’ve made a couple minor updates to the client.  First, the status window wasn’t clearing the tank and enemy condition bars when there was no tank or enemy combatant.  That’s fixed.

Next, I’ve added what appears to be working support for aliases.  They’re created accessed using the “#alias” command (#al for short).  They cannot yet be saved/loaded, but they do stay in memory as long as the client is open.  Saving/loading is probably the next thing I’ll work on.

Here’s an example:

Aliases in the Basternae Client

You can download it here.

Terry Pratchett’s Latest Books

I just finished reading Thud! and Making Money by Terry Pratchett.  They’re both excellent books, and if you haven’t read any of his work you probably ought to.  It’s sort of that British-style Douglas-Adams-y thing, but applied to fantasy instead of sci-fi.

Thud! is about a racewar brewing between Trolls and Dwarves and the cops who are trying to prevent it. Making Money is the story of an ex-crook who is put in charge of a bank via inheriting the dog that owns it.  They both have plenty of comedy-meets-fantasy-parodies-reality to them.  All on a world riding on the back of a giant turtle, of course.

You could always start with The Colour of Magic at the beginning of the series, but you’ll soon reach some of the less-than-awesome books (like Eric). If you don’t start the beginning you’ll miss out on Rincewind the incompetent wizard, Death and his companion The Death of Rats, and some of the other great characters he hasn’t done too much with lately.  Most of the books are pretty standalone, so you could start anywhere.  If you’re considering reading Thud! I’d recommend Monstrous Regiment first, and for Making Money I’d recommend Going Postal first.  They’re not essential, but they develop the background of some of the characters a bit more so you get a bit better depth.

His books make good gifts for mudders and friends of mudders, so it’s something to keep in mind if you’re getting kind of last-minute on your holiday shopping.  They’re always in stock at pretty much every bookstore.

Building The Client On Linux

It’s been 3 years since I’ve tried to build the client on Linux. I started building the client long before there ever was a Basternae 3 project, and since then plenty of files have been added and removed — for instance, we no longer use Xerces-C or SDL in the project.  I was using Ubuntu 6.06 then, and now I’m on 9.04.

After updating the old makefile, I found there were a few minor issues. Of course there was the expected forward/back slash in filenames and that’s an easy fix. There were two that were a bit of a surprise:

warning: cannot pass objects of non-POD type ‘class wxString’ through ‘...’; call will abort at runtime

error: no matching function for call to ‘wxRichTextCtrl::AddPendingEvent(wxCommandEvent)’
/usr/include/wx-2.8/wx/event.h:2400: note: candidates are: void wxEvtHandler::AddPendingEvent(wxEvent&)

The first one is because I was passing wxString arguments to the wxString::Format function.  Visual Studio was smart enough to convert those to the char* type that printf commands understand for %s, while GCC doesn’t make any assumptions and does what you tell it to rather than what you intend. Differences like that have been known to start religious wars.  Adding .c_str() to the arguments in a dozen places sorted that out for me.

The second one was a bit of a stumper, and the folks at the wxWidgets Discussion Forum helped me out. I’ve dealt with a lot of user communities for various APIs and toolkits, and the wxWidgets folks have always been the most helpful and knowledgeable.

I was able to get the client to build.  I was even able to get it to run.  I could almost even use it.  Here’s a screenshot:

Basternae Client on Linux Screenshot

The main problem with it is that the input window doesn’t actually work — you can type until you’re blue in the face but nothing ever gets sent to the MUD.  Strangely enough, if you program a hotkey and click that, the text goes across fine.  I was able to clumsily log in and fight something using that method.  I’m sure there’s some OS-specific stuff in the key handler for the input window, but that probably won’t be too daunting to figure out.

Now I’m going to have to learn how to create Debian (.deb) installer packages so I can distribute the thing.  I might also have to figure out how to do .rpm, but since I don’t run a Redhat/Fedora-based version that might be a little low on the priority list, especially since I’d have to set up VM just to build/deploy it.  I might be the only one who uses Linux that would connect to Basternae anyhow.

It would also probably not be too tough to get this working for MacOS and Solaris, but since there’s zero chance of me having a Mac to work with and the only people who run Solaris work at Sun Microsystems, those aren’t really a priority.

First Release of the Basternae 3 Client (v0.11)

You should be able to tell from the version number that it’s far from done yet.

I spent some time working on the status window, and it now appears to work more-or-less as intended:

Client status window screenshot.

There are a handful of issues I know about, and probably a good solid handful that I don’t know about, so feel free to report anything that is broken that you wouldn’t expect to be broken in a partially-done MUD client.

I’m also curious to know what this client would have to do for you to give up your current favorite MUD client, whether it be ZMud, WinTin, tintin++, or some other app.  I’ll throw one out there — before I’d be willing to use it as my main client it would have to support aliases, all those extra newlines that show up in the main window would have to go away, and room description formatting would have to be less wonky.

The cool thing about having our own client is that we’re no longer just restricted to 16 colors of ANSI text.  We could do 2-D graphics (i.e. the sample tiled map that shows when you first run the app — since we don’t have surface maps yet it won’t do anything, but hey..)  We could do any number of colors.  We could do anything we have the skills and motivation for.

I don’t at any point plan to make this client mandatory — you should always be able to play with Windows Telnet.  It’s just going to be there for those who want the “full experience”.  Tinker with it imagine some neat possibilities that I wouldn’t have thought of yet.

You can either click on the link in the sidebar (which will always have the most current version), or you can get it HERE.  There are no real instructions, but you’ll get the hang of it.  The other dialogs can be shown with the “View” menu.

Immortal ‘Set’ Commands Repaired

One of the casualties of the codebase rewrite was the disabling of the immortal ‘set’ command, which is pretty useful for administrative tinkering. It’s been repaired, so immortals are godlike once more. It doesn’t improve gameplay any, but it does help development.

Thank You To Drevarr, Nauraki, Sarim, Sarlac, and Thendar

They’ve been nice enough to grant Basternae 3 the use of their zones.

I’ve also found out that the converter needs some work — there are a few special cases that it doesn’t handle and zone format variations that it doesn’t handle perfectly yet, so it will probably be a bit before all of the zones we can use are fully converted and attached.

Some Solid Client Progress

Over the past two days I’ve made some good progress on the client.  It’s now working with colored text and functioning scrollback.  There was a bit of difficulty in figuring out how to post text from the network thread to the main window, but that’s been solved thanks to the helpful folks at the wxWidgets forums.

Client Screenshot

The equipment window works now, but the equipment names are not in color yet:

Equipment Window

The earlier screenshots of the client just had some placeholder text — now it actually processes your equipment list and displays it.

The hotkey (hot button) window also works — you right click to set a command and a hotkey name.  When you click the button the command is sent.

Hotkey Window

Hotkey Editing

The prompt processing and room info display still needs some work, but it’s coming along nicely.  I haven’t even started on the group info window yet.  I think it may be about three solid days away from being able to release a test version, but I can’t recall the last time I’ve been able to get in a “solid” day of development.  Usually it’s anywhere from one half to four hours at a time.

Visual C++ For C# Programmers

At my dayjob, I’m a C# developer. 2.5 years ago I was a C++ developer during the day. When I wrote C++, it was all for multiplatform applications that never touched any of the .NET libraries. When I switched to C#, it was all .NET. Never once did I try or even look into using any of the .NET libraries with C++. I knew there was something like __gcnew available, but I took one peek at managed C++ back in 2003 or so and got scared, running away because it looked so ugly.

I had heard that it was improved, but never bothered to look into it until now. I picked up a copy of Pro Visual C++ 2005 for C# Developers and in the first 50 pages I learned everything I need to know to be able to mix managed and unmanaged code in a C++ application, or to mix C# and C++ applications in a .NET project.  I’m not sure how much I’ll ever use that, since my main usage of C++ is for wxWidgets or Qt-based applications, but it’s nice to know, and the author, Dean Wills, did a damn fine job of explaining the differences between the two languages in a short amount of time.

The remainder of the book explains more of the intricacies and specifics, but any competent C# programmer can be writing C++ in only two hours with this book.

Minotaur Stronghold Added

The Minotaur Stronghold zone I mentioned doing some testing with a few days back is now uploaded and connected to the MUD. It’s a scenario where an Orcish army has a Minotaur outpost under siege. Enjoy!

wxWidgets Client Resurrected

As I mentioned in my post yesterday, not being able to support scrollback with the client was a problem in the wxWidgets-based version. This is because it used the Simple DirectMedia Layer (SDL) for the text rendering, and that just has a 2-D panel that text can be rendered to. Adding scrollback to that kind of system would be a large amount of effort.

Since the original development on the client was started back in 2005, wxWidgets has added the wxRichTextCtrl control, which lets you create rich text box — as in, a text box that has color, images, and all sorts of happy goodness like that.

I spent some time ripping out all of the SDL portions of the client and replacing them with the rich text control. The end result is that it does everything it did before, but has scrollback, uses less CPU, and has less memory copying going on (which means fewer possible points of failure). It still needs some tuning, but it already uses five fewer code files than the previous attempt.

WPF Is A Dealbreaker

I spent some time working on the client, only to find that the Windows Presentation Foundation doesn’t support right-click events.  That’s a deal-breaker because I need right-click support.  How could a GUI toolkit not support something so basic?

So, the wxWidgets-based client is being resurrected.  That’s good, because it was further along.  The big problem was that I couldn’t easily support scrollback with the SDL integration.  Well, since then I’ve figured out how I’d make that work.

In case you’ve forgotten or are not aware, THIS was how far along the wxWidgets-based Basternae client was last time we looked at it.

Editor Update (Version 0.45)

I added a few more commands to the walkthrough mode in the zone editor.  The commands list, edit, createedit, exits, and version have been added.  It also now understands the short versions of the diagonal commands — nw, ne, se, and sw.  You can get it HERE or via the sidebar link.

As always, this is a relatively untested app, so save often.

Basternae Code Now Stored With Assembla

Code versioning is a good thing. You can rollback changes that make things worse, compare current code to past code, keep backups, and access your code from almost anywhere. It also helps make sure that every machine being used for development is kept current and that changes aren’t easily overwritten. Any serious development should have a source code repository, especially if that development is done on more than one system or by more than one person. I’m only one person, but I used three different dev systems.

I’ve tried to set up a Subversion code repository at home twice. Both times it was on an extra laptop and both times the laptop’s hard drive died within a month of setting up the repository. I didn’t lose the code (every development machine is technically a code backup), but it was pretty frustrating.

The other day I signed up with Assembla for my audio software development and it’s been so useful that I’ve added the Basternae code too.

I’m debating whether to start using the Trac issue tracking system with Basternae 3. It works well for the Zeta Centauri projects, but the workflow here is far more organic and to-do-list based than issue-and-ticket based. I suspect the verdict will be “no” on Trac and I’ll keep using my got-it-done.com website to track Basternae.