Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUDs
➜ General
➜ Tiny MUD server - example code
Tiny MUD server - example code
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Nick Gammon
Australia (23,052 posts) Bio
Forum Administrator |
Date
| Tue 07 Jan 2003 09:10 PM (UTC) Amended on Wed 10 Nov 2004 07:49 PM (UTC) by Nick Gammon
|
Message
| 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
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Ready
(15 posts) Bio
|
Date
| Reply #1 on Thu 10 Jun 2004 02:06 PM (UTC) |
Message
| Got the file and everything but I can't extract it. It won't let me says it cant open th file. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #2 on Thu 10 Jun 2004 02:56 PM (UTC) |
Message
| Winzip sometimes stupidly adds a .tar to the .tar.gz file when you download it. You could try removing the final .tar (e.g. .tar.gz.tar becomes .tar.gz) or try a different way of downloading (e.g. save to disk instead of directly opening.) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Timbo
(1 post) Bio
|
Date
| Reply #3 on Fri 11 Jun 2004 10:40 PM (UTC) |
Message
| The problem I usually have is that .tar.gz files get saved with a different file name (and changes what's right before the last dot) when opening them from the location. This is okay with blah.zip because it becomes something like c:\temp\blah[1].zip, but with blah.tar.gz, it becomes c:\temp\blah.tar[1].gz, and that's a problem because WinZip and other programs use the filename before the .gz to determine what is in the .gz file, and ".tar[1]" doesn't make sense to it. .tgz files are okay to open from location, but need to save .tar.gz files to disk if you want WinZip to open it nicely. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #4 on Sat 12 Jun 2004 05:34 AM (UTC) |
Message
| When downloading and choosing where it saves to, in the box do this:
"blah.tar.gz"
instead of
blah.tar.gz |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Ready
(15 posts) Bio
|
Date
| Reply #5 on Sat 12 Jun 2004 06:42 PM (UTC) |
Message
| None of that works.
What happens is that the file extracts but when it extracts the folder tinymud it put out a Okb file with the name of the folder.
From then on the tar code extracted from the gzip will not extract any of the files or the folder and says there is an error opening the files.
what do i do?
| Top |
|
Posted by
| Nick Gammon
Australia (23,052 posts) Bio
Forum Administrator |
Date
| Reply #6 on Sun 13 Jun 2004 05:11 AM (UTC) |
Message
| I just tried downloading it and it worked perfectly (with WinZip).
In any case, if you are going to compile it, which you need to, and you are using Cygwin, then you can un-tar it like this:
tar xvzf tinymudserver-1.0.0.tar.gz |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Ready
(15 posts) Bio
|
Date
| Reply #7 on Mon 14 Jun 2004 03:25 PM (UTC) |
Message
| Right I've mahanged to extract it now, i wanted to compile it to just check how it works at the moment (to get the feel of it ;)
At the moment it wont let me compile because of:
g++ -g -Wall -c tinymudserver.cpp
tinymudserver.cpp:66: error: redeclaration of C++ built-in type `int'
make: *** [tinymudserver.o] Error 1
is it cos i have to add something first or what? | Top |
|
Posted by
| Nick Gammon
Australia (23,052 posts) Bio
Forum Administrator |
Date
| Reply #8 on Mon 14 Jun 2004 09:46 PM (UTC) Amended on Mon 14 Jun 2004 09:49 PM (UTC) by Nick Gammon
|
Message
| Did you look at the source code? If you edit tinymudserver.cpp and go to line 66 you see this:
/* NB - if you get errors on the "accept" line remove the typedef below */
typedef int socklen_t; // line 66
NB means "very important".
If you are planning to write a MUD server, or even change one, you need to get used to compiling code, reading C++ and generally helping yourself.
Error messages like this:
tinymudserver.cpp:66: error: redeclaration of C++ built-in type `int'
refer to line numbers in the code. In this case, line 66. The first thing you would do is open the code (the filename is given in the message, tinymudserver.cpp) and go to the line. Then see if something is obviously wrong. In this case the author (me) has put in a comment to help you.
The reason for this is some compilers have socklen_t predefined, some don't. Thus the requirement to comment or un-comment that line depending on whether you get an error or not.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Ready
(15 posts) Bio
|
Date
| Reply #9 on Wed 16 Jun 2004 02:21 PM (UTC) |
Message
| I had already tried that but I got it working in the end, thanks for your help
| Top |
|
Posted by
| Rechocto
(6 posts) Bio
|
Date
| Reply #10 on Wed 07 Jul 2004 12:51 AM (UTC) |
Message
| neither Dev cpp, or (payed for) Borland C++ Builder Pro,
seem to be able to compile it. | Top |
|
Posted by
| Nick Gammon
Australia (23,052 posts) Bio
Forum Administrator |
Date
| Reply #11 on Wed 07 Jul 2004 01:48 AM (UTC) Amended on Sun 03 Apr 2011 09:14 PM (UTC) by Nick Gammon
|
Message
| It is always nice if you say what the errors are rather than such a general report, however I tried to compile it under Dev CPP and see what you mean.
Basically the example server I posted was designed to be compiled under Linux or Cygwin. Microsoft, for reasons best known to themselves, have modified the network code somewhat and changed the names of things. For instance "read" on Linux becomes "recv" on Windows, and "write" on Linux becomes "send" on Windows. Plus, various header file changes and so on. You also need network initialisation code, and shutdown code. It isn't that bad, but can be confusing if you haven't seen it before.
I have done a variant which compiles and runs under Dev-C++ version 4.9.8.0. This can be downloaded from:
http://www.gammon.com.au/files/muds/tinymudserver_dev_cpp-1.0.0.zip
(9 Kb file).
The changes basically have "#if defined(WIN32) ... #endif" around them.
[EDIT] Changed from ftp link to http link. 4 April 2011. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nico
(1 post) Bio
|
Date
| Reply #12 on Sun 03 Apr 2011 05:35 PM (UTC) |
Message
| Hello Nick,
The link asks for a password..?
ftp://ftp.gammon.com.au/muds/tinymudserver_dev_cpp-1.0.0.zip
| Top |
|
Posted by
| Nick Gammon
Australia (23,052 posts) Bio
Forum Administrator |
Date
| Reply #13 on Sun 03 Apr 2011 09:13 PM (UTC) |
Message
| |
Posted by
| Daniel Spain
(15 posts) Bio
|
Date
| Reply #14 on Tue 24 Jul 2012 11:00 AM (UTC) |
Message
| hey Nick i used your tinymud source as a starter for my mud in c++.
i wrote a workaround to add color to message text but could you point me into a good direction to format the text so it dont breakup? if a word is too long when it hits the edge of the screen instead of taking the whole word to the next line it only takes the rest of the word ... example:
Ice is a stunningly attractive and powerfully built male gobl
in blackguard with a worldly air about him. He has a tan comp
lexion, red eyes, and black, wild, short hair. You notice that
his movements are very quick and agile. He has a bright look i
n his eyes. He is wearing elven chainmail armor, is armed with
a darksword and he appears to be wounded. You also notice a di
stinctive violet rune inscribed on his forehead.
in that block of text when looking at my player it split up the words goblin, complexion, in, and distinctive.
i as thinking maybe capture the block of text and catch where its gonna break, i dunno, its not a big deal just something i want to work on. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
64,124 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top