I am pleased to release into the public domain an example MUD server written in C++ (source only). It was developed in Unix, but should compile OK under Cygwin (on Windows) with minor changes to 'include' files.
This program is only a simple example (880 lines of code), however if you are interested in seeing how a server works, or wanting to write your own, you could use this as a basis for it.
The reason I wrote it is that somtimes I want to see how to make a simple server, but the main 'established' servers tend to be thousands of lines of code, and it is hard to see in the middle of all that code what is essential to writing a server, and what is an add-in.
The code is not copyright, so you can use it as you will. This gets around the problem that people have by deriving a server from Diku or other MUDs which have restrictive licenses on them (eg. no pay MUDs).
Download it from http://www.gammon.com.au/files/muds/tinymudserver-1.0.0.tar.gz (9 Kb).
Description
This program demonstrates a simple MUD (Multi-User Dungeon) server - in a single file.
It does the following:
- Accepts multiple connections from players
- Maintains a list of connected players
- Asks players for a name and password (in this version the password is the name)
- Implements the commands: quit, look, say, tell
- Illustrates sending messages to a single player (eg. a tell) or all players
(eg. a say)
- Handles players disconnecting or quitting
- Illustrates a 'connection dialog' - players get asked their name, then their password.
- Demonstrates using stl for lists and strings
- Illustrates period messages using a timer (at present it just shows a message every
30 seconds)
- Demonstrates using STL (Standard Template Library) for lists and string handling
What you could add
As it stands the program is too simple to be used for a full MUD, however it could be the
basis for writing your own. For instance, there is no file handling at present. You would
want to add things like this:
- Load/save player details to player files - I would suggest using XML for this
- Load messages (eg. message-of-the-day)
- Load room details (eg. area files) - again I suggest using XML
- Code for moving from room to room, taking/dropping things, etc.
- Fighting (if required)
- Building/extending online
- Logging events (eg. connections, disconnections, faults)
- Colour
- MCCP (compression)
- MXP (MUD Extension Protocol)
- Telnet negotiation
|