[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?

Tiny MUD Server - version 2

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


Pages: 1  2  3  4  5  6 7  8  

Posted by Nick Gammon   Australia  (19,173 posts)  [Biography] bio   Forum Administrator
Date Reply #75 on Sat 27 Sep 2008 07:54 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Japheth   (7 posts)  [Biography] bio
Date Reply #76 on Sun 28 Sep 2008 03:16 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (19,173 posts)  [Biography] bio   Forum Administrator
Date Reply #77 on Sun 28 Sep 2008 06:35 AM (UTC)  quote  ]
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
[Go to top] top

Posted by BrigandKing   (23 posts)  [Biography] bio
Date Reply #78 on Fri 03 Oct 2008 06:18 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (19,173 posts)  [Biography] bio   Forum Administrator
Date Reply #79 on 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

Posted by Maxhrk   USA  (76 posts)  [Biography] bio
Date Reply #80 on 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  (19,173 posts)  [Biography] bio   Forum Administrator
Date Reply #81 on 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 Javel   Poland  (3 posts)  [Biography] bio
Date Reply #82 on 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  (19,173 posts)  [Biography] bio   Forum Administrator
Date Reply #83 on 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 Reply #84 on 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 Trask   Australia  (23 posts)  [Biography] bio
Date Reply #85 on 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 David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Reply #86 on 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  (23 posts)  [Biography] bio
Date Reply #87 on 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,881 posts)  [Biography] bio   Moderator
Date Reply #88 on 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  (23 posts)  [Biography] bio
Date Reply #89 on 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

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.


61,157 views.

This is page 6, subject is 8 pages long:  [Previous page]  1  2  3  4  5  6 7  8  [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]