Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUDs ➜ General ➜ Tiny MUD Server - version 2

Tiny MUD Server - version 2

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3  4  5  6 7  8  

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #75 on Sat 27 Sep 2008 07:54 PM (UTC)
Message
I assume you are using tocapitals somewhere, as that has a bit of a bug.

In strings.cpp look for the function fCapitals, and inside that is:


    // work out whether next letter should be capitals
    bUpper = isalnum (c) == 0;


That test won't really work for extended characters, as it will fail the test 'isalnum'. It should probably read something like:


    // work out whether next letter should be capitals
    bUpper = isalnum (c) == 0 && c < 0x80;


There is no particular problem with converting to char * for extended characters, as that only fails in one case, which is 0x00, however extended characters are >= 0x80.

Admittedly it technically should probably be unsigned char *, however when casting, it doesn't actually change the underlying characters.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Japheth   (7 posts)  Bio
Date Reply #76 on Sun 28 Sep 2008 03:16 AM (UTC)
Message
Thanks for the advice Nick, it worked like a charm. I simply had assumed that extended characters didn't gel very well with c-strings as a previous project I had worked on had merely discarded them, and I didn't quite understand how the extended character sets could possibly be stored in a char.

Consequently, top notch job on Tinymud. I took tinymudserver v2 and stripped out basically everything until it was essentially just keeping track of logins, and handling input (though the only commands were quit and shutdown). I've written everything else with Object Orientation in mind, and I even had a polymorphic series of classes for characters, though I have since taken a different approach as my other developers (mostly schooled in java) didn't really understand it.

Decided to run with xml to save things, as it seems to be all the rage. It's very freeing to be working with a MUD architecture that uses proper STL libraries, streams, and actually takes advantage of C++ features rather than being a dodgy diku hack.

One question I had though - where did you learn about writing all that connectivity stuff? I mean, that's essentially what I (and probably others) are using Tinymudserver for. I've not found a lot of information on it myself.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #77 on Sun 28 Sep 2008 06:35 AM (UTC)
Message
I think I looked at Diku derivatives, and PennMUSH, in their comms handling sections, which gave the general idea of what to do. Then I read the manual about creating sockets, doing a listen, accept, etc. making sure I knew exactly why every thing was done in a certain way.

I think a lot of comms code is "take a copy of an existing one because it seems to work" - and potentially duplicating problems with obscure situations. For example, an error code returned on a read, or a write.

It also helps to find a book or web site about the theory about TCP/IP so you understand what is happening behind the scenes. Couple that with a packet sniffer so you can watch the packets fly back and forwards as you establish a connection.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by BrigandKing   (23 posts)  Bio
Date Reply #78 on Fri 03 Oct 2008 06:18 PM (UTC)
Message
Has anyone thought of adding Lua to TinyMud? Picked up the Ron Penton book and TinyMud is better IMO than the BETTERmud he has to use as a core. It has a strange quirk of not letting you repeat direction commands.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #79 on Sat 04 Oct 2008 03:19 AM (UTC)
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
Top

Posted by Maxhrk   USA  (76 posts)  Bio
Date Reply #80 on Sat 04 Oct 2008 05:56 AM (UTC)
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~
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #81 on Sun 05 Oct 2008 06:23 AM (UTC)
Message
See:

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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Javel   Poland  (3 posts)  Bio
Date Reply #82 on Fri 09 Jan 2009 10:40 PM (UTC)
Message
Hey!
How can I create new rooms?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #83 on Sat 10 Jan 2009 06:02 AM (UTC)
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
Top

Posted by Javel   Poland  (3 posts)  Bio
Date Reply #84 on Sat 10 Jan 2009 03:03 PM (UTC)
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!
Top

Posted by Trask   Australia  (23 posts)  Bio
Date Reply #85 on Tue 18 Aug 2009 11:39 AM (UTC)

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
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #86 on Tue 18 Aug 2009 05:43 PM (UTC)
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
Top

Posted by Trask   Australia  (23 posts)  Bio
Date Reply #87 on Wed 19 Aug 2009 08:51 AM (UTC)
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.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #88 on Wed 19 Aug 2009 03:48 PM (UTC)
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
Top

Posted by Trask   Australia  (23 posts)  Bio
Date Reply #89 on Wed 19 Aug 2009 04:30 PM (UTC)
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!
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.


353,698 views.

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

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.