[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUDs
. -> [Folder]  General
. . -> [Subject]  Tiny MUD Server - version 2
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Tiny MUD Server - version 2
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  3  4  5  6  7  

Posted by Nick Gammon   Australia  (15,754 posts)  [Biography] bio
Date Mon 16 Aug 2010 09:30 PM (UTC)  quote  ]
Message
The Tiny MUD server is now available for downloading from GitHub:

http://github.com/nickgammon/tinymudserver

The latest commit (f3cb4f0) fixes the problems with the missing include files.

It now compiles OK for me under:


gcc (Ubuntu 4.3.2-1ubuntu12) 4.3.2



You can clone a read-only version from GitHub like this:


git clone git://github.com/nickgammon/tinymudserver.git



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (15,754 posts)  [Biography] bio
Date Mon 16 Aug 2010 11:16 AM (UTC)  quote  ]

Amended on Mon 16 Aug 2010 11:25 AM (UTC) by Nick Gammon

Message
Thanks Hex.

Sounds like I better do an improved version that works out of the box. :-)

That's not a criticism BTW, its just that compilers keep evolving, and things that used to work, suddenly don't.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Hex   (1 post)  [Biography] bio
Date Mon 16 Aug 2010 09:59 AM (UTC)  quote  ]
Message
I just got this to compile on g++ 4.5.0.

Changes needed:

#include <algorithm>
in several files.
#include <limits>
in several files.
#include <errno.h>
in several files.
[Go to top] top

Posted by Nick Gammon   Australia  (15,754 posts)  [Biography] bio
Date Wed 19 Aug 2009 09:10 PM (UTC)  quote  ]
Message
I found it somewhat hard to get the answer quickly, so I sympathize. :)

I couldn't find it in the manual, even after installing stl-manual.

Eventually a Google for "transform" gave the answer:

http://www.sgi.com/tech/stl/transform.html

Then I hit:


player.cpp: In member function ‘void tPlayer::Load()’:
player.cpp:82: error: ‘numeric_limits’ was not declared in this scope
player.cpp:82: error: expected primary-expression before ‘int’


I had to:


#include <limits>


into a couple of files.

Oh well, this is what happens with old code. The header files used to cross-reference each other, and someone tightened it up.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Trask   Australia  (20 posts)  [Biography] bio
Date Wed 19 Aug 2009 04:30 PM (UTC)  quote  ]
Message
Thanks for the help David,

I didn't even realise I could install documentation, I'll do that at my next opportunity. I'm reading Bruce Eckel's Thinking in CPP atm, but I might have to order the Josuttis book as a progression.

Thanks again mate!
[Go to top] top

Posted by David Haley   USA  (3,824 posts)  [Biography] bio
Date Wed 19 Aug 2009 03:48 PM (UTC)  quote  ]
Message
/usr/include is where the files typically live. The problem is that the STL files go in all kinds of places underneath that. For example, on my Ubuntu system, I have this:


$ pwd
/usr/include/c++
$ find . -name algorithm
./4.1.3/algorithm
./4.1.3/ext/algorithm
./4.3/parallel/algorithm
./4.3/algorithm
./4.3/ext/algorithm
$ 


As you can see, the 'algorithm' header file exists in several places. So if you're finding something in the STL, I'd recommend first finding where your STL files live -- hopefully something like the above. Then you can grep around in there.

Another option is to install the library documentation from your package manager; then you can use 'man' to bring up the docs which usually tell you what the header is. (Unfortunately, the documentation is sometimes sketchy for STL features.)

Finally, you can use old-fashioned references like the Josuttis STL book that Nick and I both use & like.

After a while, though, you'll probably just start including the entire list of STL headers that you've needed. Sometimes I have stl.h that includes all the necessary STL header files. (To avoid compilation slowdowns, I use precompiled headers.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Trask   Australia  (20 posts)  [Biography] bio
Date Wed 19 Aug 2009 08:51 AM (UTC)  quote  ]
Message
That was the correct solution. When something in a standard library isn't found, there's a 99.9% chance that the header file wasn't included. Things were moved around in various releases of the STL, different compiler versions, and different implementations handle things differently, which is why this code compiled for Nick but didn't compile for you.


--------------------------------------------------------------------------------


I know each linux distro puts different things in different places, but is there a general area in which I could have used grep to search for the offending function? That way, I wouldn't have to rely on the internet.
[Go to top] top

Posted by David Haley   USA  (3,824 posts)  [Biography] bio
Date Tue 18 Aug 2009 05:43 PM (UTC)  quote  ]
Message
Quote:
strings.cpp: In function ‘std::string tolower(const std::string&)’:
strings.cpp:51: error: ‘transform’ was not declared in this scope
strings.cpp: In function ‘std::string tocapitals(const std::string&)’:
strings.cpp:85: error: ‘transform’ was not declared in this scope


I assume this has something to do with ctype.h?
<snip>
Would there have been a more logical way to solve this problem? As I might not always have internet access, I'd like to be more self sufficient as opposed to relying on google and your brains for answers.

That was the correct solution. When something in a standard library isn't found, there's a 99.9% chance that the header file wasn't included. Things were moved around in various releases of the STL, different compiler versions, and different implementations handle things differently, which is why this code compiled for Nick but didn't compile for you.

Quote:
Also, I noticed the STL includes toupper() and tolower() functions, so I thought you'd be able to just call that with arguments, but you've implemented your own functions tolower() and tocapitals(), using the transform() function. Is this correct, and if so, why?

I think you probably mean the standard C library, not the STL itself. The toupper and tolower functions work on one character at a time. Therefore, to work on an entire string, you transform each character of the string (one character at a time) by passing it through the appropriate function.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Trask   Australia  (20 posts)  [Biography] bio
Date Tue 18 Aug 2009 11:39 AM (UTC)  quote  ]

Amended on Tue 18 Aug 2009 12:12 PM (UTC) by Trask

Message
Hi there,

I tried compiling this with g++ 4.3.2 and seem to be hitting a snag:

strings.cpp: In function ‘std::string tolower(const std::string&)’:
strings.cpp:51: error: ‘transform’ was not declared in this scope
strings.cpp: In function ‘std::string tocapitals(const std::string&)’:
strings.cpp:85: error: ‘transform’ was not declared in this scope

I assume this has something to do with ctype.h?

Also, I noticed the STL includes toupper() and tolower() functions, so I thought you'd be able to just call that with arguments, but you've implemented your own functions tolower() and tocapitals(), using the transform() function. Is this correct, and if so, why?

Please remember I'm looking at this through newbie coloured glasses, and my interpretation of what's going on could be completely ridiculous to someone skilled in coding.

Thanks for any help.

edit: I managed to solve this myself, yay! Although it was completely without skill, I just searched for the functions in google and saw what includes they used in example code, then threw them into my code, these are the changes required for it to compile:

strings.cpp
#include <algorithm>
player.cpp
#include <algorithm>
#include <limits>
load.cpp
#include <limits>
comms.cpp
#include <algorithm>

Would there have been a more logical way to solve this problem? As I might not always have internet access, I'd like to be more self sufficient as opposed to relying on google and your brains for answers.

Cheers
[Go to top] top

Posted by Javel   Poland  (3 posts)  [Biography] bio
Date Sat 10 Jan 2009 03:03 PM (UTC)  quote  ]
Message

Thanks for the code - now I can see clearly where is my mistake - I forgot to write the room number.

Now it works!

Starting room (room 1000).
No i nie wiesz co robi&#263;. Chcesz wyj&#347;&#263; na zewn&#261;trz?
Exits: e n s tak w 
> tak
You go tak
Komnata (room 1006).
Wielka sala,
a - wró&#263; do pokoju 1000.
b - id&#378; do pokoju 1001.
Exits: a b 


Thanks for Your answer!
[Go to top] top

Posted by Nick Gammon   Australia  (15,754 posts)  [Biography] bio
Date Sat 10 Jan 2009 06:02 AM (UTC)  quote  ]
Message
Bear in mind this server is really a tutorial, rather than a working MUD.

However to answer the question, in a directory "rooms" in the download is a file "rooms.txt". In that are the room definitions.

Judging by that file the layout is:


<room number>
<description>
<exits>


For example:


1000
Starting room (room 1000).%rYou are standing in a fabulous, fabulous, exotic room, with all sorts of things that go 'hum' and 'plink' in the night.%r%rAs you glance around the room, you wonder what else might exist in this world.
n 1004 s 1001 e 1002 w 1003
1001
Room 1001.%rYou are in room 1001. It could look better. What a let-down! This rooms has no alabaster walls, no mystic fireplace, no marble floors.
n 1000


Thus room number 1000 goes north to 1004, south to 1001, east to 1002, and west to 1003.

You can also see that you put linebreaks in room descriptions with %r.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Javel   Poland  (3 posts)  [Biography] bio
Date Fri 09 Jan 2009 10:40 PM (UTC)  quote  ]
Message
Hey!
How can I create new rooms?
[Go to top] top

Posted by Nick Gammon   Australia  (15,754 posts)  [Biography] bio
Date Sun 05 Oct 2008 06:23 AM (UTC)  quote  ]
Message
See:

http://www.gammon.com.au/forum/bbshowpost.php?id=6400


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Maxhrk   USA  (76 posts)  [Biography] bio
Date Sat 04 Oct 2008 05:56 AM (UTC)  quote  ]
Message
i think i have big picture in my head that your $home directory is messy.. is it? :) be organized next time! :p

in anycase(sorry for being off-point), Your LuaMud look cool and i has good idea and experiment upon it for while.

tiny MUD server look good too, but i wonder how do I embed lua within the code.

~maxhrk~
[Go to top] top

Posted by Nick Gammon   Australia  (15,754 posts)  [Biography] bio
Date Sat 04 Oct 2008 03:19 AM (UTC)  quote  ]
Message
TinyMUD is pretty minimal - I think I actually did a Lua-based server a little while after that. Not sure where the source is though.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


30,376 views.

This is page 1, subject is 7 pages long: 1 2  3  4  5  6  7  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]