User Tools

Site Tools


user:mgough:mud-modernization

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
user:mgough:mud-modernization [2010/12/17 21:24]
mgough
user:mgough:mud-modernization [2010/12/17 21:29] (current)
mgough
Line 1: Line 1:
 +====== Resurrecting The Forest Heart MUD Codebase ======
 +I've been a fan of old-school multi-player MUD games for years. ​ I've managed to collect some of my favorites from the past that are now defunct. ​ One of the best out there was The Forest Edge - It is a very unique code base that is fun to play and lends itself very well as a skeleton to build a new game on.
 +
 +That being said, much of this code was made before C/C++ strict standardization,​ so things that compiled well in the past will not compile now.  This is my attempt to log the changes needed to bring the code back to life, I will post the final product here as well for anybody willing to use it.
 +
 +The original, unmolested code can be found in a collection here: http://​seltha.net/​tfe/​ - The mega-pack contains quite a few versions of the code (none of which will compile out of the box).  The version I will be working on is "The Forest'​s Heart" - dated 1999.
 +
 +===== Initial Overview =====
 +After decompressing the archive, navigate to directory "​tfh"​.  ​
 +The directory structure is set up to isolate source, include, player, etc.. files for easier navigation.
 +<​code>​
 +area  clans  files  inc  logs  notes  player ​ rooms  src  tables
 +</​code>​
 +
 +The *.cc files are located under the src/ directory, and any include files (*.h) will be found in the inc/ directory. ​  We will worry about the rest later.
 +
 +Navigating to the src/ directory brings up all the *.cc files as well as the Makefile. ​ There are a couple of items you want to edit in the makefile (at least as of this revision of my log) to make life easier.  ​
 +
 +Firstly we will get A LOT of spam from errors and warnings. ​ For the moment we will suppress warnings (Though, we will go back later to fix them too) so we can get to the hardcore problems first. ​ We will also supply the -fpermissive flag to further cushion some of the errors.
 +
 +This is accomplished by editing the following line:
 +<​code>​
 +  7 CFLAGS ​ = $(DEBUG) -O $(WARN) $(PROF)
 +</​code>​
 +To
 +<​code>​
 +  7 CFLAGS ​ = $(DEBUG) -O $(WARN) $(PROF) -fpermissive -w
 +</​code>​
 +
 +Now, run "​make"​ - here are the errors that I find:
 +<​code>​
 +c++ -c -ggdb -O   ​-fpermissive -w  -I. abil.cc -o ./​OBJ/​abil.o
 +In file included from struct.h:​128,​
 +                 from abil.cc:6:
 +array.h: In function 'void copy(Array<​something>&,​ Array<​something>&​)':​
 +array.h:78: error: array bound forbidden after parenthesized type-id
 +array.h:78: note: try removing the parentheses around the type-id
 +In file included from struct.h:​180,​
 +                 from abil.cc:6:
 +fight.h: In function 'void spam_char(char_data*,​ const char*, T)':
 +fight.h:​168:​ error: invalid use of incomplete type '​struct pc_data'​
 +struct.h:​39:​ error: forward declaration of '​struct pc_data'​
 +fight.h: In function 'void spam_char(char_data*,​ const char*, S, T)':
 +fight.h:​180:​ error: invalid use of incomplete type '​struct pc_data'​
 +struct.h:​39:​ error: forward declaration of '​struct pc_data'​
 +fight.h: In function 'void spam_char(char_data*,​ const char*, S, T, U)':
 +fight.h:​192:​ error: invalid use of incomplete type '​struct pc_data'​
 +struct.h:​39:​ error: forward declaration of '​struct pc_data'​
 +In file included from struct.h:​222,​
 +                 from abil.cc:6:
 +output.h: In function 'void fsend(thing_data&,​ const char*, S, T, U, V)':
 +output.h:​994:​ error: no match for '​operator<'​ in 'i < array'
 +output.h:​995:​ error: no match for '​operator[]'​ in '​array[i]'​
 +output.h: In function 'void fsend_seen(char_data*,​ const char*, S, T, U, V)':
 +output.h:​1093:​ error: '​NULl'​ was not declared in this scope
 +output.h: In function 'void send_color(char_data*,​ int, const char*, T)':
 +output.h:​1113:​ error: no matching function for call to '​send_color(char_data*&,​ int&, char [480])'​
 +output.h: In function 'void send_color(char_data*,​ int, const char*, S, T)':
 +output.h:​1124:​ error: no matching function for call to '​send_color(char_data*&,​ int&, char [480])'​
 +output.h: In function 'void send_color(char_data*,​ int, const char*, T) [with T = const char*]':​
 +abil.cc:​467: ​  ​instantiated from here
 +output.h:​1113:​ error: no matching function for call to '​send_color(char_data*&,​ int&, char [480])'​
 +make: *** [abil.o] Error 1
 +</​code>​
 +
 +Yikes!! And that is just from trying to compile the FIRST file - If your real daring, remove the -w compile flag and try to find the errors, its much like Where'​s Waldo, but less fun!
 +
 +Do not be afraid though, taking each error one at a time makes life easier.
 +
 +===== Typical Errors Found =====
 +There were really only a few common errors found, but they were repeated throughout the code.  ​
 +
 +The prime suspect I ran into was selective prototyping. ​ Most functions were prototyped in their header files, but that was not always the case... Especially overloaded functions. Apparently old GCC would compile without complaining,​ this is not the case anymore. ​ Adding the proper prototypes solved that problem.
 +
 +Typecasting on the left... or lcasting. ​ Lcasting is a big no no, but it was common practice in this code.
 +<​code>​
 +  (int)x = y;
 +</​code>​
 +This problem haunts my dreams still... it was done in a billion places, and there'​s no easy way to fix it like the prototyping problem above. ​ You have to go through one by one and edit it so that it logically works.
 +
 +The final error that was found throughout the code was functions requiring a char, but the variable being a const char, or visa-versa. ​ Again a frustrating nightmare. ​ The solution I made was to create overloaded functions that took the other argument. ​
 +
 +So if there was a function "​blah(char)"​ I created another that was "​blah(const char)"​. ​ Seemed simple enough at the outset, but it turned out to be a major typing exercise.
 +
 +In the end though, it DID compile without errors (but with plenty of warnings). ​ I must admit that I'm impressed on how stable it is.  Just take a look at this!
 +<​code>​
 +mgough@lab46:​~/​unix/​scripts$ telnet lab46.corning-cc.edu 5006
 +Trying 10.80.2.38...
 +Connected to lab46.corning-cc.edu.
 +Escape character is '​^]'​.
 +
 +0 players on.
 +System started 36 days 9 hours 41 minutes ago.
 +Getting site info ...
 +Welcome to WezlMud v0.1b
 +Enter 1 to create a new character.
 +Or enter your name if you already have one...
 +                   ​Choice:​
 +</​code>​
 +36 days of uptime is respectable for any software.
 +
 +Would I do it again? Probably.. but I'm probobably a bit crazy too...
 +
 +If you get bored, feel free to log into lab 46 and....
 +<​code>​
 +telnet lab46.coring-cc.edu 5006
 +</​code>​
 +And have fun!
 +
  
user/mgough/mud-modernization.txt · Last modified: 2010/12/17 21:29 by mgough