Removing Hard-Coded Rooms, Objects, and Mobs

The old codebase had plenty of references to hard-coded room numbers. For instance, “Limbo” and the “default start room” for races without hometowns were set to room number 200.

Well, having those etched permanently into code is a bad idea, since it ties you inextricably to certain specific area files, and more importantly, it forces “zone gods” to dig into code if they want to change some things with how rooms are used. Bad idea.

The interim solution I’ve come up with isn’t great, but it does at least take the specific numbers out of code. I’ve created some XML files that load at boot time: StaticRooms.xml, StaticObjects.xml, and StaticMobs.xml. They contains a list of room, object, or mob names and their numbers, storing them in a Dictionary type. This makes it easy to refer to “ROOM_NUMBER_START” or “ROOM_NUMBER_LIMBO” in code and not worry too much about where it actually points. Of course, those names are still hard-coded, but at least they can be administered by non-programmers now.

I’d like to have them load dynamically as part of the zones, but there’s a bit of a problem there — some bits are just far too tightly integrated, especially things that revolve around locations, such as shifting to the astral or prime material plane. Those problems are better tackled in a future design change. This incremental improvement is good enough for now.