Author Archives: xangis

Repop Points

Setting up hometown repop points for the various races and classes in Basternae 2 was a real pain.

We had, in code, a two-dimensional array that would be referenced to get the room number for each particular race/class combination. Any special cases where someone had a choice or more than one hometown had to be hand-coded. If an area was added or removed, the code would have to be touched. This invariably resulted either in zone admins editing code (a bad idea), or in zone admins waiting for a coder to add their changes (better idea, but slower).

I’ve created a way to automatically generate hometown lookups based on areas loaded and give a new player a choice of which hometown to take when they create a character. It’s simple enough in theory: each zone can list the races that can choose it as a hometown and lists the room numbers where the various classes respawn. When the zones load, the MUD builds a list and everything is spiffy, no code editing involved.

Behind the scenes it’s a little complex. I’m using a two-dimensional vector of lists that point to integers ( std::vector< std::vector< std::list<int *> * > * > ). The standard library is awesome and makes life much easier, but it can result in excessive punctiation, as seen in the previous sentence.

I really prefer moving as much as possible out of code and into configuration files. I mean, isn’t it silly to have to recompile to, say, make a troll mercenary spawn one room to the left?

SourceMonitor Update

I just love these statistics tools…

Files: 127
Lines: 116,320
Statements: 60,630
% Branches: 29.5
% Comments: 8.5
Class Definitions: 50
Methods/Class: 7.04
Average Statements/Method: 10.8
Max Complexity: 477
Max Depth: 8
Average Depth: 1.87
Average Complexity: 11.71

The number of files, class definitions, and methods per class has increased, while the statements per method and average complexity has decreased.

XML Files

Traditionally MUDs I’ve seen have used raw text files for player files. Some might use binary, and some might compress them into a gzipped format.

There’s a problem with using this sort of file: in general, they are written or read a single line at at time. In Basternae 2 we had a significant problem with player file corruption. If the save or load engine had a problem with one of the values found in the file, you were pretty much screwed. If this happened during a file save, you pretty much had to restore the player file from a backup and hope that the backup was recent.

In order to banish this problem to the realms of oblivion, I’m incorporating the XML-based file save/load code that I used on my AlgoRhythmia 3 application. The difference with this code is that instead of opening the file and writing it line by line, dealing with values as they come, instead it creates an XML data store in memory and populates that with the values, and then serializes it to disk after all the values are checked.

So, intstead of having a half-written player file if the values are bad, it’ll be an all-or-nothing. If the data store fails to build, the file won’t be written, so instead of losing up to a week worth of play data, at most about 15 minutes would be lost, and that assumes the player hadn’t picked up or dropped any items in that time.

Once I have this code done I may give serious thought to setting up all of the game files to use XML. In addition to the build-then-save, XML also some built in checks and guards, so a typo in a hand-edited file would be much less likely to destroy the universe.

The downside: XML files are larger and slower.

The other upside: Data files written in XML can be easily processed by other applications, such as a web script that posts dynamic game stats on a page.

Project Line Counter Update

I’ve done a lot of writing, rewriting, replacing, and rearranging lately. Here are the current totals:

115,384 lines total
93,783 lines of code
9,859 lines of comments
2,071 mixed (code + comment) lines
13,813 blank lines

I guess you could call that a small but not quite negligible increase.

WinMerge

One of my biggest complaints when booting into Linux is that I don’t have access to a merge tool quite as nice as WinMerge. The current version of WinMerge doesn’t run under Wine, but apparently an older version, 2.0.2, will.

Some things are optional when writing code, but a good merge tool is not one of them. WinMerge is the perfect example of what a merge tool should be.

The Meld diff viewer is the best merge tool that I’ve seen on Linux, but it’s just a bit less usable than WinMerge.

SourceMonitor

I found a code analysis and metrics program called SourceMonitor today. I downloaded version 2.3.6.1 and fed it the source files for Basternae. Here’s what it came up with:

Files: 120
Lines: 114,121
Statements: 59,490
% Branches: 29.2
% Comments: 8.6
Class Definitions: 43
Methods/Class: 4.41
Average Statements/Method: 14.2
Max Complexity: 477
Max Depth: 8
Average Depth: 1.87
Average Complexity: 12.41

The check_command() function in the command interpreter is the most complex function. The complexity rating of 477 comes from the fact that it has 477 different branches of execution – essentially 1 for each different command the MUD understands.

Since this code is hybrid C and C++, the average number of statements per method metric doesn’t giev a full picture of things. It’s still pretty interesting to see the statistics on things.

SourceMonitor keeps track of “checkpoints” and lets you look at how code evolves over time, so it’ll be interesting to fire it up and post statistics now and then.

Astyle Rocks!

I’m EXTREMELY picky about the formatting of my code. There are a few commonly-known formats for code: ANSI, Kerninghan & Ritchie, GNU, Linux, and Java.

I have a a very strong preference for ANSI style, but with one minor modification: I like my switch statement case labels to be indented. That’s not a strong preference, as long as the brackets look right.

This drives me nuts (ARRR!):

if( a == b ) {
return;
}

This makes me happy:

if( a == b )
{
return;
}

So, the fact that a lot of code has the former annoys me every time I see it, and I either change it, or frown and move on.

Today I discovered an excellent program, astyle:

http://astyle.sourceforge.net/

It lets you choose what formatting to give your code, goes through it all, and changes it to be however you want. The way I think code should be is:

astyle –style=ansi -s4 –indent-switches

All of a sudden it looks pretty, and I can read it without twitching. Not only does it do everything I mentioned Visual Studio doing in my May 15th post, it also rearranges brackets to be where I want them.

It’s very unlikely that I’ll bring on any programmers, but if I do, I’ll definitely have a stated “official lysanctioned” code formatting style.

The Road To C++

I’ve gradually been changing more pieces of code from C to C++. As each piece goes from being a random function dangling somewhere to a piece of a coherent class the code begins to make a little more sense.

So many bits and pieces are going to benefit from being private data members. In a lot of cases there were hoops that had to be jumped through to handle values properly. Race, for instance. If a character was polymorphed into another race, some of the functions in the game would react to the new race and others would react as if nothing had happened, so a troll turned into a lizard might still lumber into the room.

With the ability to make some data members private, we can make it so that nobody can look at player->race, but instead have to call player->GetRace() which will be smart enough to check for polymorph. The same can be said for checking or adjusting ability scores, hitpoints, and all sorts of things that can be modified by spells.

It’s a phenomenally massive undertaking, but with the proper amounts of time and insanity it can be done right.

Goodbye Shared Strings

Shared string management has been completely removed from the code. Gone. Done for.

The result: greater stability at the cost of higher memory requirements and a slight reduction in processor power requirements (which aren’t even a concern). The removal automagically fixed a few bugs due to the less-than-perfect shared string management.

Next task: Getting Thendar’s zones attached and loading. Some load code modifications will probably be needed.

Code Reformatting

One thing I’ve always found annoying is the way that different applications and operating systems handle tabs. In some programs a tab will move you over 4 spaces. Other apps will have different sizes, like 5 or 6 spaces. This can cause things that line up in one app to look totally out of whack on another.

When editing code this can be very annoying, especially if you check things by seeing whether braces line up and visually analyzing code flow.

Just yesterday I discovered some neat tools in Microsoft Visual Studio that I had never known about. They are edit->advanced->untabify and edit->advanced->format. What that does is convert all the tabs in a file to spaces and then reformat it according to the Visual Studio automatic formatting rules, which are perfectly aligned with my personal preferences. Because all the tabs are now spaces the file will look the same in any editor.

Editing code just got a whole lot less annoying.

Lines and Lines of Code

One of my favorite free little toys for Microsoft Visual Studio is the Project Line Counter (http://www.codeproject.com/macro/linecount.asp). A count of the current Basternae codebase shows:

110,815 lines total
89,446 lines of code
9,880 lines of comments
2,003 mixed (code + comment) lines
13,492 blank lines

Progress continues on changing to std::string, constructors and destructors, and converting manually-handled lists (direct pointer-setting) to std::list.

Hammering and Tinkering

I’ve been ripping and tearing a bit more and there have been quite a few internal changes:

  • Much of the use of char * has been replaced with std::string, which is a bit more powerful and somewhat safer.
  • Almost all of the shared string routines are no longer being used and the shared string manager will be removed soon.  This means that the MUD will take up more memory, but will ultimately end up being more stable and less prone to “string weirdness”, segfaults, etc.  The shared string manager was a fine idea in 1996 when the typical desktop system was a Pentium 1 running at somewhere between 60 and 150 MHz and would typically have about 16-32MB of RAM.  In fact, most MUD codebases were designed to run well on a slowish 486 PC (i.e. 486DX-33).  I remember Illustrium Arcana, the first MUD I worked on, being SUPER SUPER FAST on a Cyrix 6×86 200MHz processor with 32MB of RAM.
  • Many of the “new” and “free” routines that were used in the C code have been converted to constructors and destructors.  This is good because we don’t have to worry whether a creation or destruction routine is called on a mob, object, room, etc.  The initialization and deinitialization how happens automagically.
  • Two zones have been connected and are loading – the Thri-Kreen hometown Thannik’Tzil and the Kobold Village, both written by me.
  • I’ve been exchanging emails with Thendar and she has granted permission to use all of her zones – Plateau, L’strizzen, Ice Palace, Gypsy Quest, Court of the Muse, and a few others.

It’s still just running on my home PC and is far from stable (I still have quite a lot of major changes to make too), but it is gradually coming together to look like something.

And It Begins

I’ve been working with the old Magma 3.0 codebase for almost a week now. Things I’ve done so far:

  • Removed all of the old outdated OS-specific code (Sequent, Apollo, Amiga).
  • Removed all instances of sprintf (a very dangerous function prone to buffer overflows). These have been replaced with snprintf, which is safer. Over 1000 functions have been replaced.
  • Converted all major structs to classes (a C to C++ conversion).
  • Broken the single monolithic merc.h header file into many different header files in order to make the code easier to maintain.

I’m also working on removing or replacing most of the old predecessor code and adding support for just about every area format I can find.  When this is all over it will be a full codebase rewrite in C++.

The goal is to build an engine that is easily extended and modified, with OLC, easy-to-add mods and scripts, and plenty of ways to add fun things to the game without it being too unstable. Original Magma was incredibly unstable because it was built in a hurry — the codebase was based on reverse-engineering the format of existing areas for Basternae 1. There was very little testing at first and it took years for the engine to fully develop into a robust form.

It may take a few years for this new engine to develop into a fully robust form, too, but this programmer knows a vast amount more than he did eight years ago when building Basternae 2 was begun.

Review: Suicide Commando – Mindstrip (2000)

I originally wrote this review for Darksonus.com, which no longer exists.

Track List:

  1. Jesus Wept

  2. Hellraiser (Psychopath 01-Version)

  3. Body Count Proceed

  4. Raise Your God

  5. Mindstripper

  6. Run

  7. Comatose Delusion (Overdose Shot Two)

  8. Blood In Face

  9. Love Breeds Suicide

  10. Slaves

Sounds: 3.5 of 5

Vocals: 3 of 5

Composition: 3 of 5

Overall Rating: .633

My overall reaction to Johan Van Roy’s Belgian project was indifference.

The sample quality of Jesus Wept is fairly low. Yeah, industrial is supposed to sound dirty and noisy, but there’s a difference between noisy and low-quality. I like distorted vocals. Most industrial takes a few listens to really understand what the heck they’re saying. Suicide Commando may have taken it half a notch too far into the unintelligible range.

Hellraiser starts off with a great synth sound until it turns into techno. By this time I was beginning to think this was a techno or synthpop group that had picked up a distortion pedal at a pawn shop. I will say the actual sounds used in this song are quite cool and the vocal quality is a bit better than Jesus Wept.

The techno-esque extravaganza continued with Body Count Proceed. The drone synth sound made me feel like I was having a hole drilled in my skull. In a bad way. Even so, the beat was rather contagious and I couldn’t help but tap my appendages on the nearest solid surface. Since I was at work I had to keep it to a minimum. Can’t have the boss walking in while you’re tapping your bits on the monitor, you know. That’s more explaining that I’d care to do.

By the time I reached Raise Your God, something was starting to bug me about the whole Suicide Commando formula. Yet again it was an average song that didn’t particularly stand out for me. It wasn’t something I loved nor was it something I hated.

I can honestly sum up the rest of the disc fairly easily. Just like the first few songs. Nothing that stands out as overly good or bad though I would say that Comatose Delusion is the best song on the disc and Blood In Face came the closest to trying my patience. Although this is nothing but your run of the mill industrial, it is decent overall. Anything’s better than Paula Spears or Britney Abdul or whatever they’re calling that pseudo-musical genre now. Will I see them live if they come around? Yes. Will I tell all my friends to pick up this disc? No.

Suicide Commando sounds a remarkably large amount like Velvet Acid Christ, and if you like them you might as well pick this up. Overall the music isn’t terribly creative and more follows the EBM/industrial “formula”, obviously influenced by their tour with Velvet Acid Christ, though Suicide Commando doesn’t do it as well. Don’t get me wrong, I still like the stuff, but as filler rather than foreground.

Review: And One – Virgin Superstar (2000)

I originally wrote this review for Darksonus.com, which no longer exists.

  1. Virgin Superstar

  2. Wasted

  3. You Don’t Love Me Anymore

  4. Goodbye Germany

  5. Wet Spot

  6. Panzermensch

  7. My Story

  8. Life To Lose

  9. Not The Only One

  10. Don’t Need The Drugs

  11. Mr. Jenka

Vocals: 4.5 of 5

Sounds: 3.0 of 5

Composition: 3.5 of 5

Overall: .733

And One is a fairly popular EBM group whose tunes are heard on goth/industrial club nights around the world. It’s not surprising, because it’s very difficult to listen to And One without some part of your body wanting to move around. Sure, being EBM some of their stuff is a little too techno for my liking, but they are quite good overall.

“Virgin Superstar” isn’t what I would call the strongest opener. Although the vocal harmony is great (which you’ll get used to on this disc), there’s not all that much to the music.

The song “Wasted” starts off the disc with a nice hard danceable beat. The line “Get out of my way because you know that I am totally wasted” is a classic and tends to stick in your head. Good for stumbling through a bar to.

“You Don’t Love Me Anymore” is a synthpoppy sort of tune that really fails to grab me. It’s put together well, but it just doesn’t stand out, sounding a little bland to me.

“Goodbye Germany” doesn’t stand out too much musically, and the vocals don’t do much until the chorus. All in all, this is a “take it or leave it” song, but the chorus does tend to stick in your head if you let it.

For this album, And One absorbed Annelie Bertilsson from Cat Rapes Dog and I’d bet that she was glad to get out of that pseudo-musical abomination (see our review of Trojan Whores). Listening to “Wet Spot”, It becomes obvious that Annelie has more musical talent than is deserved by Cat Rapes Dog. It starts off with an ambient feel and then the synthesizer line starts with an almost a James Bond “The World Is Not Enough” feel to it. Both vocalists sound great on this song and the man sitting behind the mixing console certainly earned his paycheck.

What can I say about the song “Panzermensch”? Well, I can say that the synth sounds are absolutely amazing and the vibe of the song is intense. It hits hard and is one of the most danceable songs I’ve ever heard (and if you’ve ever been to a club where most everyone knows this song, the dancefloor tends to go completely nuts). I’ve never been one to buy a disc based on hearing one song, but in this case I would make an exception. The lyrics are in German, but it’s my opinion that most good industrial lyrics are in German. There’s something about the language that just sounds more factory-fresh than the same phrases in English. It’s no wonder this song has become one of their hits.

“My Story” has a nice string line, but there’s not much to say about it. It’s not terribly interesting, nor terribly worth my time talking about. Too techno.

I love the crystal bell synth sound that opens “Life to Lose”, but it gives no indication what to expect for the song itself. Unfortunately it looks like very little effort went into the music, but the vocals almost make up for it.

“Not The Only One” is yet another song that has a more of the “James Bond” essence to it – in the string line at least. This song is much more synthpop than EBM, which seems to be the direction And One is moving in slowly but surely.

“Don’t Need The Drugs?” I love the song. It is a little on the Depeche Mode side, though, which isn’t my cup of tea. Even so, it is an excellent song with a great arrangement and sound all over the place.

And One does a very good job of filling up the sound palette. The vocal harmonies are very good, with Annelie blending so well with Steve Naghavi that in some places their voices might as well just be one.

If you like EBM, you’ll probably like And One, although this disc is a bit patchy with only a few of the songs qualifying as great (which seems to be an ongoing habit of And One). If you don’t like EBM and/or synthpop, it’d be a good idea to pass this disc by, because that’s exactly what this disc is.

And One is Steve Naghavi on vocals and “machines”, Rick Schah on keyboards, Annelie Bertilsson on vocals, and Joke Jay on drums. This disc was produced by Steve Naghavi and Christer Hermodsson.

And One’s website is at http://www.andone.de/

Review: Cat Rapes Dog – Trojan Whores (1992)

I originally wrote this review for Darksonus.com, which no longer exists.

  1. Trojan Whores

  2. Everything’s Gone Green (New Order cover)

  3. 909 Whores

Sounds: 3 of 5

Vocals: 1.5 of 5

Composition: 2.5 of 5

Overall Rating: .467

Most people probably have not heard of this Swedish group. The name might have something to do with it. The fact that they’re not very good might also contribute. One source refers to them as “punkelectro”, while another refers to them as industrial. Cat Rapes Dog is, however, a truly industrial band. Their early jam sessions were conducted in a factory where member Joel Rydstrom was working. At night, they would spend hours banging on sheets of metal with iron poles hoping the boss would not catch them.

While the lyrics to Trojan Whores are nothing short of brilliant with lines like “Open the doors, open the doors, I have a horse full of whores” and “This war ain’t no game anymore, this is a horse and it’s full of whores”, Everything’s Gone Green is nothing short of awful. The distortion does very little to hide how off-key singer Joel Rydstrom is (in fact, in an interview he admits that he had the idea to hide his awful vocals using distortion while seeing Ogre at a Skinny Puppy show), while the female vocalist sounds like she has had one too many Valium. In fact, either one sounds like they could throw up on themselves at any time during the song. The accompanying music is typical of European electronic dance music of the era, neither brilliant nor awful, just “average” drum-machine-and-synthesizer background. The accompanying guitar work is noticeably out of time in places, but blends into the mix fairly well.

Although they are influenced by Skinny Puppy, Cabaret Voltaire, and Einsturzende Neubauten, they somehow manage to completely fail to take the music to the next level. Had they not included the butchering of New Order’s Everything’s Gone Green, this disc would have scored higher. You may find it amusing, but Cat Rapes Dog likely to only find a permenant home in a music collection based on its novelty value. Although not very mass-marketable, the name has a certain ring to it.

If you want more information on Cat Rapes Dog, their official website is: http://crd.se/CRD.SE/HEM.html