Re: [Circle] C++ Cirlce Mud worth the effort?

From: Christopher J. Dickey (cjd@esca.com)
Date: 11/01/96


  If only for the extra type checking C++ does, it's worth it ;).  But
seriously, it's rather easy to at least compile your mud in C++, after
all C++ is a derivative of C.  I did this to my mud originally for the
above reason and cause I prefer C++ to C for mud writing.  However, I
don't think it's worth the effort to convert CircleMud to C++ primarily
because it's has spent so many years evolving as a C mud that it becomes
to big of a chore to try to create objects and wrench them into procedural
code.

  Really the hardest part of a C++ mud is deciding how exactly you are
gonna develop your classes.  I chose the route of making a generic object
called thing, which any physical object in the mud inherits, and then I
wrote a socket class which any object in the mud requiring socket
communications will inherit.  So, in essence, you have something like:

                   thing
                     |
  -------------------------------------------------
  |        |         |         |        |         |
 door     room     zone      world    mobile    object




Many of the objects also inherit container classes, which vary depending
on need, so that for example, a world contains a list of zones, a zone
contains a list of rooms and mobiles, contain lists of objects (note that
list here does not necessarily specify a particular data structure as it
may change from case to case as I thought best).  With polymorphism, you
can create alot of neat variations on the above classes with minimul
coding.

  Personally, I don't use streams for input and output.  They're a little
bit bulky for my needs, and I wrote a string sharing class which ends up
being faster than a stream or a standard string class.  You can very
easily overload the socket class so that you can use stream-style input
and output though.  For example:

ch << "Look, just like a stream";

ch << "You see " << num << " dwarves.";

Nice thing about that is that it gets type checked before it compiles, so
your code doesn't have to parse a bunch of %d and such out of your string
constantly.  In addition, there's also a file class that gets inherited by
classes which need to be written with virtual write functions so that all
inherited objects know how to read/write themselves to the disk.


  Muds just seem to fall naturally under C++ programming once you get
yourself thinking in that mode.  I agree there are some good C muds out
there, but when its only one person (in my case) handling the code, I feel
that C++ is easier to maintain and modify.

-cjd

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST