Sean Middleditch » 2003 » May

Inline Scripts

Something I’ve been against previously is the embedding of Scriptix scripts inside of the AweMUD zone files. I’ve recently (last night) changed my mind on that, and today implemented the feature.

Before, say you needed a script to trigger on some event in an area in the MUD. You’d have to define the event trigger in the area, and give it a script function name to call. Then in a script file you’d have to define the function, make sure you had the right argument list, and export the function publicly (so the event system could find it). This polluted the function namespace, and didn’t deal with clashing event function names well at all.

Now you can just put the script right in the area file. No need to pollute namespaces, or worry about clashing functions, or even about remembering the exact argument list to use. This is even better for small event scripts, since it was too much work for the effect previously.

The only problem with the current implementation is the wasted memory; the source of the script is stored in memory with the event, so when it’s saved back to disk it is available. Compilation happens using a temporary file. I’d like to just use temporary files to store the script body, and not use up system memory; getting permanent (or semi-permanent) temporary files is a pita, tho; I’m just using tmpfile() for now for the compilation.

In any event, with how easy it is to drop in small event scripts now, I’ve already made the very small example world in AweMUD seem a bit more alive. I’m quite pleased.

Releases

Released new versions of AweMUD and Scriptix. Very pleased with myself for getting work done on these lately. ^,^

Next big task up for AweMUD is getting the online editing/building working well. It’s only half-functional currently, and more functional would be more useful to the MUD builders.

MUD Protocol

I’m also looking at the various out-of-band MUD protocols, for things like enhanced MUD client features. (i.e., showing health bars and such.) The current protocols I’ve found seem to have been designed while under the influence; this includes both MCP and MXP.

I’m thinking that since the MUD already runs over telnet, why not just use the existing telnet protocol to its fullest? Instead of inventing a crack escaping protocol like MCP, or a weird moded protocol like MXP, just use the telnet sub-request/option codes for escaping into “command mode.”

The command mode would be, simply, a command name and a list of parameters. The command and all parameters would be separated by NUL bytes; binary data can just be encoded. (Who needs binary data here, anyway, in a MUD protocol?) This makes it very generic and flexible, since it is now basically an RPC framework; you can use it for things as simple as setting colour (command: “colour\0red”) or sending tell messages (command: “msgfrom\0bobby\0what’s up?”), to as complex as online editing (command: “setroom\0forest\0title\0Dark forest”).

The protocol is easily coded to work both ways, since both client and server need to support telnet anyhow. It’s gonna be great. When I get around to it. ;-)

Music

Bought a couple new CDs at the mall today: Celtic Women, and Kashmir: Symphonic Led Zeppelin. Both are very good. The former I bought as I enjoy Loreena McKennit, who is celtic-music inspired, and thought I might enjoy it. (Which I do.) Symphonic Led Zeppelin is something I’ve wanted for a while; my last attempt at purchasing it ended up in me getting a String Quartet tribute to Zeppelin which, while good, is nothing compared to the beauty of a full symphany playing Kashmir or Battle of Evermore. ^,^

Coding

Lots and lots of Scriptix work. Still a lot more to do. But the compiler is largely no longer crack-inspired. Which is a Good Thing(tm).

Future work will be based mostly on cleaning up the internals. For example, variables in a function call currently make use of a special variable array. While it’s speedy, and made compiling a bit easier, it’s a bit of a kludge. I’m thinking to instead just store variables on the normal data stack; which means of course I need the compiler to work out allocating space, and knowing which location to peek/poke for the variable values.

Also still want a C++ binding API, similar to Boost Python. I’ve still not figured out how to make templates work like that for me; C++ can be a massively tricky beast like that. As great as generic functions are, I think a more powerful preprocessor would be a better idea - imagine being able to define new operators or syntactical constructs (like a decent foreach implementation to the C# 2.0/Scriptix one) as one can do in other languages. I wonder how hard it would be to write such a pre-processor? I’d probably need a full C++ parser to do it right.

Socialization

The other night I bothered to stop being an anti-social dink and contacted an old friend from high school. We hung out for a few hours earlier today; ran out and got lunch, stopped at the mall.

Had a lot of fun. Felt a bit awkward tho, not sure why; either I’m just really not used to hanging out with women anymore, or I managed to annoy her greatly. (Which wouldn’t be surprising.) Still, hoping we can do it again before she leaves back to school - cool person to hang out with. ^,^

Best friend was supposed to call this weekend to hang out, but I guess he’s stuck working. He works in a park, so the holiday weekends tend to be rather busy for him.

X2

I’ve seen X2 at work. My boss doesn’t suffer from my moral integrity in regards to pirating. I’m fully planning on seeing it in the theatre tomorrow tho. Seeing how good it is (despite the low-quality; it was some guy with a camcorder in a theatre, basically), I’m making the family see the first X-Men (which they hadn’t yet) so I can take them to see X2 Sunday.

I’m really not much of a sci-fi fan, but the X-Men movies are pretty awesome. I think it might be because the “mutant powers” are so much closer to magic than anything you could realistically attribute to physical mutation.

Especially ones like Storm - Halle Berry would be awesome playing one of the Seven Sisters in a Forgotten Realms film. (Heck, one of them is named Storm; but the X-Men storm reminded me more of the Simbul.) And, btw, I’ve heard tell that there is going to be a Forgotten Realms TV series. I really hope the people responsible for Hercules and Xena have nothing to do with it tho; the only good parts of those directors is their friendship with Bruce Campbell. ;-)

Anyways, X2 was loads better than Matrix Reloaded. The Matrix sequel was a hallow core lacking everything except special effects; and then those weren’t even that impressive. Doubting another movie will be so cool in my mind as X2 until Return of the King is out… ;-)

Powersupply

Noooo! Midnight last night, just as I was about to go to bed, my server reboots. “WTF?” thinks I. I thought I had perhaps been rooted, and spent the next 40 minutes scouring logs (to find nothing), checking binaries, checking processes, monitoring net acitivity, etc.

12:40am - server just up and powers off. “Something isn’t right here.” Hit power switch, nothing happens. Just about to reach behind and pull the power plug and the server powers back on by itself. Now I know something weird is happening. After it’s booted back up, I again reach around to start removing screws for the sidepanel (to look inside) and the case nearly burns me. It appears the damnable powersupply’s cooling stopped working.

So, until I get off work today, I have no server at home. No e-mail. No e-mail! I think I’m going to be sick…. ;-)

Mind Games

Right, so I officially suffer from “despair” now. They can’t even call it depression, no, they have to label it despair and give me anti-despair medication.

Funnily, I didn’t even think I was. It appears a lot of my “symptoms” tho (like, for example, my inability to concentrate on work I’ve been complaining about) are side-effects of depression/despair, and the pills do seem to be helping.

When I stop and think about it tho, I think I should’ve said something to the doctor sooner; it’s actually kinda obvious I was depressed more than usual. I think I’m just so used to it I didn’t notice… ;-)

Iterators

So, since I’m concentrating on coding again, i started working on some outstanding problems in Scriptix yesterday. I have been using the Ruby-style iterators; anonymous functions passed to a method that gets called for each item in a list. It’s flexible because the method can take arguments, so instead of just a plain foreach() method, you could have foreach(Integer) or something. In order to work right tho, you needed all sorts of complex things like closures and the like. It was a pain, had ugly syntax, slowed down the engine (too much support code), and wasn’t even that flexible in certain situations.

Last week I saw a write-up on the C# 2.0 features. One of them is the new iterator feature. It’s simply beautiful. It’s extremely similiar to C++ iterators, only it provides a sane syntactical sugar coating. Basically, a method returns an iterator object. Just like the Ruby way, your method can take arguments and use these to customize the iterator object returned. (For example, to return an iterator to only go over integer members of an array.)

The syntax sugar is a simple foreach construct. It uses a simple foreach (name in list) statement; syntax. The list can either be a list type (like an array) where the iterator is autogenerated, or it can be an iterator object.

Example Scriptix Iterators
// Print all objects in the roomforeach(object in room.objects()) {printl(object.get_name());}

// Print out an arrayforeach(item in my_array) {printl(item);}

// Directly invoke iteratorlist = room.characters();while (char = list.next()) {printl(char.get_name());}

Angry Pixels

Slowed back down again. We’re now debating on the engine to use. Some members feel that we need to write a whole engine from scratch, while others (just as myself) think that’s a complete waste of many months or years worth of time.

I’m not sure I’m allowed to mention which engines we are looking at, but suffice to say, there’s a lot of debate going on over it all… :(

Music

Picked up The String Quartet Tribute to Led Zeppelin. Brilliant. ^,^ Little on the high-pitch sometimes (hurts my ears) but for the most part, it’s beautiful. Just more testament to how amazing the music of Led Zeppelin is, that it can be reborn into something like this.

Too bad Robert Plant sucked at the Who/Plant concert I saw last summer. His sound engineers were either drunk or incompetant; you couldn’t make out any of the music or singing while he was on stage. When The Who came on, it was crystal clear. (And exceptionally good, I might add.)

Scary

I made a couple kids cry today just by looking at them. At one time (all of highschool) I’d have been superbly proud of myself for that effect. Now, I was just mad at myself; why I can’t I break the habit of trying to look as menacing and scary as possible in public? Antisocialness is annoying. ;-)

I tried to pay attention to my behaviour the rest of the time at the mall, and honestly, I was going to effort to looking scary, altho it’s all but subconscious now. My mouth pulls into a half-sneer, my eyes narrow a la Clint Eastwood, and I walk like I’m about to march up to someone and beat the hell out of them. Compare this to how I look at work, where my mouth in a half-smile most the time, my eyes are inquisitive, and my walk is almost too laid back… Need to talk to psychologist about this, and if there’s some good method for breaking habits like that.

On the other hand, I got a lot of positive looks from several people; I think the working out is paying off, if more slowly than I’d like. (damn metabolism, blaming it all on that.) Probably could have gotten a date if I’d just spoken to a couple of those people… ah well.

Code

The inspiration to how to get AweMUD to be dynamic enough finally hit me. I was looking at Diablo II screenshots (never played it) and saw the item enhancement lists in the inventory; things like “+2 to Strength”, “+3 to Light Radius”, and so on. I don’t know how to explain my thought process on this, but it was something like “hmm, they have statically defined properties on objects/characters, while AweMUD is all dynamic attribute trees. You can’t easily map those.” And then, I was like, “wait… I can just use a dynamic _list_ of properties with simple definitions, and objects can have property modifiers, and this is all in _addition_ to the more complex attribute trees.” I wrote down a couple examples, and the system looks like it would work.

I’m also thinking on how I could map a property list into the attribute tree. While I know it’s possible, I don’t think it would be as efficient, and besides, I don’t think there’s any good _reason_ to do it. None I can think of, anyways.

The Angry Pixels game work is starting to pull together now I think. Starting a new project is always hard. Especially when you have 8 people from the start. ;-) In my experience, most projects start with one/two people writing a foundation, and extra hackers slowly coming on to the project. At this stage, 8 people is way too many. But once we get past it, we should be all good.

Documentation

I’ve lately been documenting the systems/modules I write for the software I’m working on. This isn’t something I usually do. I’m quite glad that I’ve done it lately.

I’m hoping this habit sticks with me. ^,^

Just as proof of how geeky I am, I’m thrilled with myself for the first-ever manpage I’ve written, for AweMUD. Go me!

Sarge GCC

It seems GCC 3 is now the default compiler in Debian/Sarge. I’m rather ecstatic about this; I’ve been doing some weird hacks for my development environment here at home. My coding folders are shared over NFS; the server is a Debian/Sarge box, and the clients are a mixture of RedHat 9, Debian/Sid, and FreeBSD 5.0. When I was logged in remotely from work coding, the projects would be compiled with GCC 2, or need to be reconfigured to use the gcc-3 binary. Now I don’t have to deal with it. Yay!

Of course, it’s still a pain with the FreeBSD box since I have to recompile everything when I switch between it and a Linux box. :(

I wonder if there’s some easy way to do a kind of local CVS repository; keep the code on the server, check out local copies and my various boxen, and check them back in when I’m ready. It’d have to sync with the SourceForge CVS server for the projects, tho. Not sure whether that would be easy, or reliable.

School

Somehow, I passed my final in Calculus with an A. Not sure how, but I did. Yay for me!

Anyways, starting next week, I’ll be taking Psychology (yay) and Accounting II (not-yay). Once the semester is over in mid/late summer, I’ll do the whole cut-hours-from-work thing to have more time for classes.

Setuid

Hopefully I did this right. If an app is run by root, both it’s UID and it’s effective UID will be 0. If the app is setuid root and run by a user, it’s UID will be non-0, and it’s effective UID will be 0. So a safe way to check if an app is run setuid root is to see if the UID is non-0 and the effective UID is 0.

I’m using this in a library that uses an environment variable to look for paths; this library could be used in setuid root apps, and I don’t want users to be able to circumvent security on the machine.

Libprefix

I’ve long held a hatred for RPM, DPKG, and all the Linux package formats. The ports systems in BSDs and Gentoo and such are just as horrible. I don’t think there’s too much reason to state why, the inferiorities of all these package systems has been stated over and over by others often enough. So, I started looking into the autopackage project. If you haven’t seen it yet, I suggest taking a look, and lending a hand if you have the time and inclination.

Anyway, one problem with most binary software in UNIX is that the paths are almost always hard-coded. If you run ./configure –prefix=/usr/local, the app will be told that it’s data is always in /usr/local. You can’t then install it in /usr, or /opt/$appname, or $HOME, or anything. This sucks for RPMs and other packages, especially for cross distro compatibility. And especially when running on a system that chucks out the brain-dead archaic FHS and uses something a little more intelligent.

The autopackage folks started working on a libprefixdb, which is basically a library to allow apps to find the prefix they were installed in. The apps would dynamically look up their prefix, and use the path returned to find their data files.This is a lot like how pkg-config works, except it’s for run-time instead of compile time.

In interest of expanding this library to be more generally useful (i.e., allowing truly disparate directory structures, versus just a prefix and relative paths), I started hacking up my own little libprefix, either as an example or to replace libprefixdb. The idea is to allow any directory/path to be configured in a config file; the app asks for the “libdir” path of the “foobar” app, the file is found and loaded and the specified path is returned.

The tricky bit is when there is no path config file. It should be possible to make an educated guess where the data files are; on Linux at least, you can use /proc/self/exe to find out where the executable running is, and guess the prefix from there. A library can use /proc/self/maps, find the address of a symbol in the list, and get the library. Ya, ya, ugly, but it should work. It’s the autopackage folks’ idea; I’m not too keen on it, but if it works, what the hey. ~,^ Running into a few issues, but confident I can figure it all out. And on the upside, package can always just drop in the libprefix conf file for the app/library, and not worry about the hacky auto-guessing stuff. :)

So ya, that’s what I’m going right now.