[Home]HowToCompileMud

TheSourcery | RecentChanges | Preferences | Index | RSS

Difference (from prior major revision) (minor diff, author diff)

Changed: 1,621c1,665
This is a annotated log of me intalling Rot under Cygwin.
I had never seen Rot before. But I will be going under the assumption that
a Diku is Diku no matter how many times they rename it. You've seen one
you've seen them all.

Now what packages did I need beyond the basic cygwin install.
This command lists all the installed packages.


jlambert@agamemnon /c/muds/Rot/src
$ cygcheck -c
Cygwin Package Information
Package Version Status
binutils 20040312-1 OK
crypt 1.1-1 OK
gcc 3.3.1-3 OK
make 3.80-1 OK
nano 1.2.2-1 OK
tcsh 6.12.00-7 OK


The above was editted down to the ones you need that I don't believe are
installed by default but have to be selected by running the setup program
again. To check for each package you can also do cygcheck -c packagename

BTW the Pico editor comes with Pine mail program. Nano has more features
though. There are also Vim, Xemacs, and a bunch of other editors.
DO NOT use a Windows editor to edit your source code or makefiles unless
it preserves Unix style line endings and in the case of makefiles tab
characters. Ultraedit, Multiedit and Textpad are Windows editors that
can read and write unix text files without munging them up. Don't use
Windows Notepad on anything, not even files on windows. :-P If you really
must Wordpad will get you through most files with messing them up.

Onward

First let's unpack the distribution somewhere.


jlambert@agamemnon /c/muds
$ ls Rot*
Rot1.4.tar.gz

jlambert@agamemnon /c/muds
$ gunzip Rot1.4.tar.gz

jlambert@agamemnon /c/muds
$ tar xf Rot1.4.tar


Note: If you use Winzip there are some empty directories that won't be created.
(i.e. bin, log, player, gods)

Let's find the install doc. Haha. None at all. Just the old Merc files.
I wasn't really planning on reading the instructions anyway. Good thing
there ain't any. :-P
Let's find a configure or makefile somewhere. There's a makefile
in the src directory.

Let's run make then.


jlambert@agamemnon /c/muds
$ cd Rot/src

jlambert@agamemnon /c/muds/Rot/src
$ make
gcc -c -Wall -O -g act_comm.c
gcc -c -Wall -O -g act_enter.c
gcc -c -Wall -O -g act_info.c
act_info.c: In function `do_look':
act_info.c:1373: warning: suggest explicit braces to avoid ambiguous `else'
act_info.c:1382: warning: suggest explicit braces to avoid ambiguous `else'
act_info.c: In function `do_password':
act_info.c:3610: warning: implicit declaration of function `crypt'
act_info.c:3610: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
act_info.c:3627: warning: assignment makes pointer from integer without a cast
gcc -c -Wall -O -g act_move.c
gcc -c -Wall -O -g act_obj.c
act_obj.c: In function `do_put':
act_obj.c:756: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:801: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:844: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:886: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c: In function `get_cost':
act_obj.c:3322: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g act_wiz.c
gcc -c -Wall -O -g alias.c
gcc -c -Wall -O -g ban.c
gcc -c -Wall -O -g clans.c
gcc -c -Wall -O -g comm.c
comm.c: In function `main':
comm.c:442: warning: implicit declaration of function `close'
comm.c: In function `read_from_descriptor':
comm.c:1399: warning: implicit declaration of function `read'
comm.c: In function `write_to_descriptor':
comm.c:1867: warning: implicit declaration of function `write'
comm.c: In function `nanny':
comm.c:2010: warning: implicit declaration of function `crypt'
comm.c:2010: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
comm.c:2172: warning: assignment makes pointer from integer without a cast
comm.c:2195: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
gcc -c -Wall -O -g const.c
gcc -c -Wall -O -g curse.c
gcc -c -Wall -O -g db.c
db.c:60: error: conflicting types for `random'
/usr/include/stdlib.h:163: error: previous declaration of `random'
db.c:61: error: conflicting types for `srandom'
/usr/include/stdlib.h:164: error: previous declaration of `srandom'
db.c: In function `do_dump':
db.c:2982: warning: long int format, unsigned int arg (arg 4)
db.c:2998: warning: long int format, unsigned int arg (arg 4)
db.c:2998: warning: long int format, unsigned int arg (arg 6)
db.c:3006: warning: long int format, unsigned int arg (arg 4)
db.c:3006: warning: long int format, unsigned int arg (arg 6)
db.c:3016: warning: long int format, unsigned int arg (arg 4)
db.c:3016: warning: long int format, unsigned int arg (arg 6)
db.c:3028: warning: long int format, unsigned int arg (arg 4)
db.c:3043: warning: long int format, unsigned int arg (arg 4)
db.c:3043: warning: long int format, unsigned int arg (arg 6)
db.c:3051: warning: long int format, unsigned int arg (arg 4)
db.c:3051: warning: long int format, unsigned int arg (arg 6)
db.c:3055: warning: long int format, unsigned int arg (arg 4)
db.c:3059: warning: long int format, unsigned int arg (arg 4)
make: *** [db.o] Error 1


The warnings above may cause problems later on. We'll just ignore
them for now and looks at the errors.

db.c:60: error: conflicting types for `random'
/usr/include/stdlib.h:163: error: previous declaration of `random'
db.c:61: error: conflicting types for `srandom'
/usr/include/stdlib.h:164: error: previous declaration of `srandom'

Let's look at these lines 60-61 in db.c


jlambert@agamemnon /c/muds/Rot/src
$ nano +60 db.c

#if !defined(OLD_RAND)
long random(); <--- line 60
void srandom(unsigned int); <--- line 61
int getpid();
time_t time(time_t *tloc);
#endif


Poor programming practices. Don't prototype system functions. This
code will cause errors on many other unixes too.


#ifndef __CYGWIN__ <--- added
#if !defined(OLD_RAND)
long random();
void srandom(unsigned int);
int getpid();
time_t time(time_t *tloc);
#endif
#endif <--- added


This effectively makes this code invisible for our CYGWIN version,
while not affecting our compiling on other machines. __CYGWIN__ is a
macro automatically defined by our gcc configuration when we our
compiling under cygwin.

Aside: One thing to check. Issue this command in your cygwin shell.

jlambert@agamemnon /c/downloads/muds
$ set | grep unix
MAKE_MODE=unix

You should get the above output. I will assume you did.

Anyway let's save the makefile (CTL-X in nano) and try make again.


jlambert@agamemnon /c/muds/Rot/src
$ make
gcc -c -Wall -O -g db.c
db.c: In function `do_dump':
db.c:2984: warning: long int format, unsigned int arg (arg 4)
db.c:3000: warning: long int format, unsigned int arg (arg 4)
db.c:3000: warning: long int format, unsigned int arg (arg 6)
db.c:3008: warning: long int format, unsigned int arg (arg 4)
db.c:3008: warning: long int format, unsigned int arg (arg 6)
db.c:3018: warning: long int format, unsigned int arg (arg 4)
db.c:3018: warning: long int format, unsigned int arg (arg 6)
db.c:3030: warning: long int format, unsigned int arg (arg 4)
db.c:3045: warning: long int format, unsigned int arg (arg 4)
db.c:3045: warning: long int format, unsigned int arg (arg 6)
db.c:3053: warning: long int format, unsigned int arg (arg 4)
db.c:3053: warning: long int format, unsigned int arg (arg 6)
db.c:3057: warning: long int format, unsigned int arg (arg 4)
db.c:3061: warning: long int format, unsigned int arg (arg 4)
db.c: In function `init_mm':
db.c:3214: warning: implicit declaration of function `getpid'
gcc -c -Wall -O -g db2.c
gcc -c -Wall -O -g effects.c
gcc -c -Wall -O -g fight.c
fight.c: In function `one_hit':
fight.c:722: warning: suggest explicit braces to avoid ambiguous `else'
fight.c:728: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `one_hit_mock':
fight.c:1071: warning: suggest explicit braces to avoid ambiguous `else'
fight.c:1077: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `damage':
fight.c:1375: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `damage_old':
fight.c:1794: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g finger.c
gcc -c -Wall -O -g flags.c
gcc -c -Wall -O -g forget.c
gcc -c -Wall -O -g handler.c
handler.c: In function `reset_char':
handler.c:632: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `get_max_train':
handler.c:828: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `unequip_char':
handler.c:1782: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g healer.c
gcc -c -Wall -O -g interp.c
gcc -c -Wall -O -g note.c
gcc -c -Wall -O -g lookup.c
gcc -c -Wall -O -g magic.c
magic.c: In function `obj_cast_spell':
magic.c:812: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g magic2.c
gcc -c -Wall -O -g music.c
gcc -c -Wall -O -g recycle.c
gcc -c -Wall -O -g repent.c
gcc -c -Wall -O -g save.c
gcc -c -Wall -O -g scan.c
gcc -c -Wall -O -g sign.c
gcc -c -Wall -O -g skills.c
gcc -c -Wall -O -g special.c
gcc -c -Wall -O -g tables.c
gcc -c -Wall -O -g update.c
gcc -c -Wall -O -g wizlist.c
rm -f rot
gcc -O -g -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o act_wiz.
o alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o fight.o fing
er.o flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.o magic2
.o music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o tables.o u
pdate.o wizlist.o
act_info.o(.text+0xa59c): In function `do_password':
/c/muds/Rot/src/act_info.c:3610: undefined reference to `_crypt'
act_info.o(.text+0xa633):/c/muds/Rot/src/act_info.c:3627: undefined reference to `_crypt'
comm.o(.text+0x385e): In function `nanny':
/c/muds/Rot/src/comm.c:2010: undefined reference to `_crypt'
comm.o(.text+0x3e85):/c/muds/Rot/src/comm.c:2172: undefined reference to `_crypt'
comm.o(.text+0x3f19):/c/muds/Rot/src/comm.c:2195: undefined reference to `_crypt'
collect2: ld returned 1 exit status
make: *** [rot] Error 1


We got much further. Everything has compiled successfully. However we are unable to
link together our object modules into an executable. It appears the linker cannot
find a system function know as crypt. (The leading underscore can be ignored as
it's C's way of mangling function names).

Many systems don't come with the crypt library installed and/or don't include
it in the linker's default list of libraries.


jlambert@agamemnon /c/muds/Rot/src
$ find /lib -name libcrypt.a
/lib/libcrypt.a


Yep I have it. So we need to update the Makefile to include it manually.


jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

L_FLAGS = $(PROF) -lcrypt <--- added crypt library


The -l flag will tell the linker to include the library when linking.
Note the naming convention differences from how the file is named and how
one includes it.

Let's see what happens:


jlambert@agamemnon /c/muds/Rot/src
$ make
rm -f rot
gcc -O -g -lcrypt -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o
act_wiz.o alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o figh
t.o finger.o flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.
o magic2.o music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o ta
bles.o update.o wizlist.o
act_info.o(.text+0xa59c): In function `do_password':
/c/muds/Rot/src/act_info.c:3610: undefined reference to `_crypt'
act_info.o(.text+0xa633):/c/muds/Rot/src/act_info.c:3627: undefined reference to `_crypt'
comm.o(.text+0x385e): In function `nanny':
/c/muds/Rot/src/comm.c:2010: undefined reference to `_crypt'
comm.o(.text+0x3e85):/c/muds/Rot/src/comm.c:2172: undefined reference to `_crypt'
comm.o(.text+0x3f19):/c/muds/Rot/src/comm.c:2195: undefined reference to `_crypt'
collect2: ld returned 1 exit status
make: *** [rot] Error 1


What?! Still can't find it. Why? The linker searches libraries from left to
right and only for those functions called by an object file. So we need to
place our -lcrypt after the object files (.o files) otherwise it'll never
be searched for anything. The is probably where your typical newbie gives up
and says cygwin just doesn't plain work with crypt.

Let's edit the makefile again


jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

L_FLAGS = $(PROF) <-- put this back the way it was
... and down below
rot: $(ROT_FILES)
rm -f rot
$(CC) $(L_FLAGS) -o rot $(ROT_FILES) -lcrypt <-- add our library here


Now save and try again...


jlambert@agamemnon /c/muds/Rot/src
$ make
rm -f rot
gcc -O -g -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o act_wiz
.o alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o fight.o fin
ger.o flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.o magic
2.o music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o tables.o
update.o wizlist.o -lcrypt


Voila! We've successfully compiled and linked Rot on cygwin.


jlambert@agamemnon /c/muds/Rot/src
$ ls rot*
rot.exe


There it is.

On to the script.


jlambert@agamemnon /c/muds/Rot/src
$ cd ../area

jlambert@agamemnon /c/muds/Rot/area
$ ls star*
startup

jlambert@agamemnon /c/muds/Rot/area
$ cat startup
#!/bin/csh

set areapath = /Rot/area
set port = 4000
set wwwport = 4001

cd $areapath

# Set limits.
if ( -e shutdown.txt ) rm -f shutdown.txt

while ( 1 )
# If you want to have logs in a different directory,
# change the 'set logfile' line to reflect the directory name.
set index = 1000
while ( 1 )
set logfile = ../log/$index.log
if ( ! -e $logfile ) break
@ index++
end

# Copy rot binary from bin directory.
# after a compile, place the new binary in the bin directory,
# this way a reboot will install the new binary, instead of
# of having to shut down.
rm -f ./rot
cp ../bin/rot .
# Run rot.
./rot $port $wwwport >&! $logfile

# Restart, giving old connections a chance to die.
if ( -e shutdown.txt ) then
rm -f shutdown.txt
exit 0
endif
sleep 15
end


Note the very first line of the script. It contains the sharp-bang (or bangline)
which is used to to indicate what program or shell will be used to run the
this script. This script was written for csh or the c-shell.

Looks like this mud will run by default on ports 4000 and 4001 (webserver?).
There are a couple of potential problems here, so we'll edit it.


jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

First..

set areapath = /Rot/area

That's not my absolute path to the area directory, let's change that to mine.

set areapath = /c/muds/Rot/area

Second...
rm -f ./rot
cp ../bin/rot .
# Run rot.
./rot $port $wwwport >&! $logfile

Cygwin executables use the .exe extension so this needs to be.
rm -f ./rot.exe
cp ../bin/rot.exe .
# Run rot.exe
./rot.exe $port $wwwport >&! $logfile


How odd. Looks like the script assumes the Rot executable is in the bin directory.
It ain't friggin' there. I guess we'll copy it there manually for now.


jlambert@agamemnon /c/muds/Rot/area
$ cp ../src/rot.exe ../bin


Note: The script above apparently can be run from anywhere as the statement,
cd $areapath, guarantees all the relative paths will be from the area directory.

So let's run it.


jlambert@agamemnon /c/muds/Rot/area
$ ./startup &
[1] 3736


The & parameter causes the script to run in the background. If you didn't
use it, your console session would be locked up until the mud shutdown.


jlambert@agamemnon /c/muds/Rot/area
$ ps
PID PPID PGID WINPID TTY UID STIME COMMAND
3760 1 3760 3760 con 1004 13:03:49 /usr/bin/bash
3736 3760 3736 2908 con 1004 14:58:48 /usr/bin/tcsh
2856 3736 3736 2084 con 1004 14:58:49 /c/muds/Rot/area/rot
2152 3760 2152 1484 con 1004 14:58:52 /usr/bin/ps


Looks like it's running.


jlambert@agamemnon /c/muds/Rot/area
$ telnet localhost 4000
Trying 127.0.0.1...
Connected to agamemnon.
Escape character is '^]'.


This is Greeting #3

Original DikuMUD by Hans Staerfeldt, Katja Nyboe,
Tom Madsen, Michael Seifert, and Sebastian Hammer
Based on MERC 2.1 code by Hatchet, Furey, and Kahn
ROM 2.4 copyright (c) 1993-1995 Russ Taylor
ROT 1.4 copyright (c) 1996-1997 Russ Walsh

What name do you wish to use? Tyche
....etc


I went ahead and created a character and quit.
So how do I make myself a god? Shrug no friggin' documentation at all.
Well knowing a little about ROM I expect I'll have to edit the player
file.


jlambert@agamemnon /c/muds/Rot/area
$ cd ../player

jlambert@agamemnon /c/muds/rot/player
$ ls
Tyche

jlambert@agamemnon /c/muds/rot/player
$ nano Tyche

#PLAYER
Name Tyche~
Id 1070395428
LogO 1070395520
Vers 5
Prom <%hhp %mm %vmv> ~
Race human~
Sex 1
Clas mage~
Levl 110 <--- changed from 1 to 110
Tru 60 <--- added this line
Plyd 92
Notb 0 0 0 0 0 0
...etc


Let's make the changes above, save, telnet back in and
try a few commands.


What name do you wish to use? Tyche
Password:
Welcome Immortal!

<100hp 100m 100mv> who
Visible Immortals:
[IMP Human Mag] Tyche the Novice of Magic


Looks like I'm an IMP.


<100hp 100m 100mv> goto Hassan
The Temple Of Thoth
You are in the southern end of the temple hall in the Temple of Thoth.
The temple has been constructed from giant marble blocks, eternal in
appearance, and most of the walls are covered by ancient wall paintings
picturing gods, giants and peasants.
A small doorway leads to the west.
Large steps lead down through the grand temple gate, descending the huge
mound upon which the temple is built and ends on the temple square below.
Equally large steps lead UP through a small door into the ENTRANCE to MUD
SCHOOL. (type 'up' to go to MUD SCHOOL.) A small plaque is on this wall.
[.......L....] Hassan is here, waiting to dispense some justice.

<100hp 100m 100mv> slay h
You slay him in cold blood!
Hassan's heart is torn from his chest.


Oooo looks like I move and fight like I have super ninja mojo powers too.
I can't wait to do that to my first player!. :-P

Now let's check out the web page. Let's bring up IE and use the
URL http://127.0.0.1:4001

Hmmm something happened. I got kicked off and the mud apparently crashed
and burned.


jlambert@agamemnon /c/muds/rot/log
$ ps
PID PPID PGID WINPID TTY UID STIME COMMAND
3760 1 3760 3760 con 1004 13:03:49 /usr/bin/bash
3736 3760 3736 2908 con 1004 14:58:48 /usr/bin/tcsh
3188 3736 3736 2384 con 1004 16:22:09 /c/muds/Rot/area/rot
4088 3760 4088 1400 con 1004 16:25:14 /usr/bin/ps


But it looks like the script was able to restart it as you see above.
So what happened? Let's check the log!


jlambert@agamemnon /c/muds/rot/log
$ cd ../log

jlambert@agamemnon /c/muds/rot/log
$ ls
1000.log 1001.log

jlambert@agamemnon /c/muds/rot/log
$ tail 1000.log
Tue Dec 2 15:05:20 2003 :: Tyche has quit.
Tue Dec 2 16:10:58 2003 :: Sock.sinaddr: 127.0.0.1
Tue Dec 2 16:11:01 2003 :: Loading Tyche.
Tue Dec 2 16:11:03 2003 :: Tyche@localhost has connected.
Tue Dec 2 16:14:19 2003 :: Tyche has quit.
Tue Dec 2 16:17:25 2003 :: Sock.sinaddr: 127.0.0.1
Tue Dec 2 16:17:27 2003 :: Loading Tyche.
Tue Dec 2 16:17:30 2003 :: Tyche@localhost has connected.
Tue Dec 2 16:21:48 2003 :: [*****] BUG: WWW-Who: fopen
/home/WWW/cgi-bin/output/rot.who: No such file or directory


Apparently the web interface crashes the mud when it can't find
a file. That's real slick.

Let's look a the new log our script started.


jlambert@agamemnon /c/muds/rot/log
$ tail 1001.log
Tue Dec 2 16:22:09 2003 :: reading social.are
Tue Dec 2 16:22:09 2003 :: Fixing exits.
Tue Dec 2 16:22:09 2003 :: Area Update.
Tue Dec 2 16:22:09 2003 :: Loading Moveable Exits.
Tue Dec 2 16:22:09 2003 :: Loading Notes.
Tue Dec 2 16:22:09 2003 :: Loading Bans.
Tue Dec 2 16:22:09 2003 :: Loading Wizlist.
Tue Dec 2 16:22:09 2003 :: Loading Clanlists.
Tue Dec 2 16:22:09 2003 :: Loading Songs.
Tue Dec 2 16:22:09 2003 :: ROT is ready to rock on ports 4000 and 4001.


Apparently Rot is NOT ready to rock on port 4001!

How to fix that? That's best left as an exercise for you, the Rot monkey.

HTH
This is a annotated log of me intalling Rot under Cygwin. I had never seen Rot before. But I will be going under the assumption that a Diku is Diku no matter how many times they rename it. You've seen one, you've seen them all.


Now what packages did I need beyond the basic cygwin install.

This command lists all the installed packages.


jlambert@agamemnon /c/muds/Rot/src
$ cygcheck -c

Cygwin Package Information
Package Version Status
binutils 20040312-1 OK
crypt 1.1-1 OK
gcc 3.3.1-3 OK
make 3.80-1 OK
nano 1.2.2-1 OK
tcsh 6.12.00-7 OK



The above was editted down to the ones you need that I don't believe are installed by default but have to be selected by running the setup program again. To check for each package you can also do cygcheck -c packagename

BTW the Pico editor comes with Pine mail program. Nano has more features though. There are also Vim, Xemacs, and a bunch of other editors. DO NOT use a Windows editor to edit your source code or makefiles unless it preserves Unix style line endings and in the case of makefiles tab characters. Ultraedit, Multiedit and Textpad are Windows editors that can read and write unix text files without munging them up. Don't use Windows Notepad on anything, not even files on windows. If you really must Wordpad will get you through most files without messing them up.


Onward



First let's unpack the distribution somewhere.


jlambert@agamemnon /c/muds
$ ls Rot*
Rot1.4.tar.gz

jlambert@agamemnon /c/muds
$ gunzip Rot1.4.tar.gz

jlambert@agamemnon /c/muds
$ tar xf Rot1.4.tar




Note: If you use Winzip there are some empty directories that won't be created.

(i.e. bin, log, player, gods)



Let's find the install doc. Haha. None at all. Just the old Merc files.

I wasn't really planning on reading the instructions anyway. Good thing there ain't any. :-P

Let's find a configure or makefile somewhere. There's a makefile in the src directory.


Let's run make then.



jlambert@agamemnon /c/muds
$ cd Rot/src

jlambert@agamemnon /c/muds/Rot/src
$ make
gcc -c -Wall -O -g act_comm.c
gcc -c -Wall -O -g act_enter.c
gcc -c -Wall -O -g act_info.c
act_info.c: In function `do_look':
act_info.c:1373: warning: suggest explicit braces to avoid ambiguous `else'
act_info.c:1382: warning: suggest explicit braces to avoid ambiguous `else'
act_info.c: In function `do_password':
act_info.c:3610: warning: implicit declaration of function `crypt'
act_info.c:3610: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
act_info.c:3627: warning: assignment makes pointer from integer without a cast
gcc -c -Wall -O -g act_move.c
gcc -c -Wall -O -g act_obj.c
act_obj.c: In function `do_put':
act_obj.c:756: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:801: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:844: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:886: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c: In function `get_cost':
act_obj.c:3322: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g act_wiz.c
gcc -c -Wall -O -g alias.c
gcc -c -Wall -O -g ban.c
gcc -c -Wall -O -g clans.c
gcc -c -Wall -O -g comm.c
comm.c: In function `main':
comm.c:442: warning: implicit declaration of function `close'
comm.c: In function `read_from_descriptor':
comm.c:1399: warning: implicit declaration of function `read'
comm.c: In function `write_to_descriptor':
comm.c:1867: warning: implicit declaration of function `write'
comm.c: In function `nanny':
comm.c:2010: warning: implicit declaration of function `crypt'
comm.c:2010: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
comm.c:2172: warning: assignment makes pointer from integer without a cast
comm.c:2195: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
gcc -c -Wall -O -g const.c
gcc -c -Wall -O -g curse.c
gcc -c -Wall -O -g db.c
db.c:60: error: conflicting types for `random'
/usr/include/stdlib.h:163: error: previous declaration of `random'
db.c:61: error: conflicting types for `srandom'
/usr/include/stdlib.h:164: error: previous declaration of `srandom'
db.c: In function `do_dump':
db.c:2982: warning: long int format, unsigned int arg (arg 4)
db.c:2998: warning: long int format, unsigned int arg (arg 4)
db.c:2998: warning: long int format, unsigned int arg (arg 6)
db.c:3006: warning: long int format, unsigned int arg (arg 4)
db.c:3006: warning: long int format, unsigned int arg (arg 6)
db.c:3016: warning: long int format, unsigned int arg (arg 4)
db.c:3016: warning: long int format, unsigned int arg (arg 6)
db.c:3028: warning: long int format, unsigned int arg (arg 4)
db.c:3043: warning: long int format, unsigned int arg (arg 4)
db.c:3043: warning: long int format, unsigned int arg (arg 6)
db.c:3051: warning: long int format, unsigned int arg (arg 4)
db.c:3051: warning: long int format, unsigned int arg (arg 6)
db.c:3055: warning: long int format, unsigned int arg (arg 4)
db.c:3059: warning: long int format, unsigned int arg (arg 4)
make: *** [db.o] Error 1



The warnings above may cause problems later on. We'll just ignore them for now and look at the errors.


db.c:60: error: conflicting types for `random'

/usr/include/stdlib.h:163: error: previous declaration of `random'

db.c:61: error: conflicting types for `srandom'

/usr/include/stdlib.h:164: error: previous declaration of `srandom'


Let's look at these lines 60-61 in db.c


jlambert@agamemnon /c/muds/Rot/src
$ nano +60 db.c

#if !defined(OLD_RAND)
long random(); <--- line 60
void srandom(unsigned int); <--- line 61
int getpid();
time_t time(time_t *tloc);
#endif


Poor programming practices. Don't prototype system functions. This code will cause errors on many other unixes too.



#ifndef __CYGWIN__ <--- added
#if !defined(OLD_RAND)
long random();
void srandom(unsigned int);
int getpid();
time_t time(time_t *tloc);
#endif
#endif <--- added



This effectively makes this code invisible for our CYGWIN version, while not affecting our compiling on other machines. __CYGWIN__ is a macro automatically defined by our gcc configuration when we our compiling under cygwin.


Aside: One thing to check. Issue this command in your cygwin shell.


jlambert@agamemnon /c/downloads/muds
$ set | grep unix
MAKE_MODE=unix


You should get the above output. I will assume you did.


Anyway let's save the makefile (CTL-X in nano) and try make again.



jlambert@agamemnon /c/muds/Rot/src
$ make
gcc -c -Wall -O -g db.c
db.c: In function `do_dump':
db.c:2984: warning: long int format, unsigned int arg (arg 4)
db.c:3000: warning: long int format, unsigned int arg (arg 4)
db.c:3000: warning: long int format, unsigned int arg (arg 6)
db.c:3008: warning: long int format, unsigned int arg (arg 4)
db.c:3008: warning: long int format, unsigned int arg (arg 6)
db.c:3018: warning: long int format, unsigned int arg (arg 4)
db.c:3018: warning: long int format, unsigned int arg (arg 6)
db.c:3030: warning: long int format, unsigned int arg (arg 4)
db.c:3045: warning: long int format, unsigned int arg (arg 4)
db.c:3045: warning: long int format, unsigned int arg (arg 6)
db.c:3053: warning: long int format, unsigned int arg (arg 4)
db.c:3053: warning: long int format, unsigned int arg (arg 6)
db.c:3057: warning: long int format, unsigned int arg (arg 4)
db.c:3061: warning: long int format, unsigned int arg (arg 4)
db.c: In function `init_mm':
db.c:3214: warning: implicit declaration of function `getpid'
gcc -c -Wall -O -g db2.c
gcc -c -Wall -O -g effects.c
gcc -c -Wall -O -g fight.c
fight.c: In function `one_hit':
fight.c:722: warning: suggest explicit braces to avoid ambiguous `else'
fight.c:728: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `one_hit_mock':
fight.c:1071: warning: suggest explicit braces to avoid ambiguous `else'
fight.c:1077: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `damage':
fight.c:1375: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `damage_old':
fight.c:1794: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g finger.c
gcc -c -Wall -O -g flags.c
gcc -c -Wall -O -g forget.c
gcc -c -Wall -O -g handler.c
handler.c: In function `reset_char':
handler.c:632: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `get_max_train':
handler.c:828: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `unequip_char':
handler.c:1782: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g healer.c
gcc -c -Wall -O -g interp.c
gcc -c -Wall -O -g note.c
gcc -c -Wall -O -g lookup.c
gcc -c -Wall -O -g magic.c
magic.c: In function `obj_cast_spell':
magic.c:812: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g magic2.c
gcc -c -Wall -O -g music.c
gcc -c -Wall -O -g recycle.c
gcc -c -Wall -O -g repent.c
gcc -c -Wall -O -g save.c
gcc -c -Wall -O -g scan.c
gcc -c -Wall -O -g sign.c
gcc -c -Wall -O -g skills.c
gcc -c -Wall -O -g special.c
gcc -c -Wall -O -g tables.c
gcc -c -Wall -O -g update.c
gcc -c -Wall -O -g wizlist.c
rm -f rot
gcc -O -g -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o act_wiz.o
alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o fight.o finger.o
flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.o magic2.o
music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o tables.o update.o
wizlist.o
act_info.o(.text+0xa59c): In function `do_password':
/c/muds/Rot/src/act_info.c:3610: undefined reference to `_crypt'
act_info.o(.text+0xa633):/c/muds/Rot/src/act_info.c:3627: undefined reference to `_crypt'
comm.o(.text+0x385e): In function `nanny':
/c/muds/Rot/src/comm.c:2010: undefined reference to `_crypt'
comm.o(.text+0x3e85):/c/muds/Rot/src/comm.c:2172: undefined reference to `_crypt'
comm.o(.text+0x3f19):/c/muds/Rot/src/comm.c:2195: undefined reference to `_crypt'
collect2: ld returned 1 exit status
make: *** [rot] Error 1



We got much further. Everything has compiled successfully. However we are unable to link together our object modules into an executable. It appears the linker cannot find a system function know as crypt. (The leading underscore can be ignored as it's C's way of mangling function names).

Many systems don't come with the crypt library installed and/or don't include it in the linker's default list of libraries.



jlambert@agamemnon /c/muds/Rot/src
$ find /lib -name libcrypt.a
/lib/libcrypt.a



Yep I have it. So we need to update the Makefile to include it manually.



jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

L_FLAGS = $(PROF) -lcrypt <--- added crypt library



The -l flag will tell the linker to include the library when linking.
Note the naming convention differences from how the file is named and how one includes it.

Let's see what happens:


jlambert@agamemnon /c/muds/Rot/src
$ make
rm -f rot
gcc -O -g -lcrypt -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o
act_wiz.o alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o fight.o
finger.o flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.o
magic2.o music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o tables.o
update.o wizlist.o
act_info.o(.text+0xa59c): In function `do_password':
/c/muds/Rot/src/act_info.c:3610: undefined reference to `_crypt'
act_info.o(.text+0xa633):/c/muds/Rot/src/act_info.c:3627: undefined reference to `_crypt'
comm.o(.text+0x385e): In function `nanny':
/c/muds/Rot/src/comm.c:2010: undefined reference to `_crypt'
comm.o(.text+0x3e85):/c/muds/Rot/src/comm.c:2172: undefined reference to `_crypt'
comm.o(.text+0x3f19):/c/muds/Rot/src/comm.c:2195: undefined reference to `_crypt'
collect2: ld returned 1 exit status
make: *** [rot] Error 1



What?! Still can't find it. Why? The linker searches libraries from left to right and only for those functions called by an object file. So we need to place our -lcrypt after the object files (.o files) otherwise it'll never
be searched for anything. The is probably where your typical newbie gives up and says cygwin just doesn't plain work with crypt.

Let's edit the makefile again...


jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

L_FLAGS = $(PROF) <-- put this back the way it was
... and down below
rot: $(ROT_FILES)
rm -f rot
$(CC) $(L_FLAGS) -o rot $(ROT_FILES) -lcrypt <-- add our library here



Now save and try again...



jlambert@agamemnon /c/muds/Rot/src
$ make
rm -f rot
gcc -O -g -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o act_wiz.o
alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o fight.o finger.o
flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.o magic2.o
music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o tables.o
update.o wizlist.o -lcrypt



Voila! We've successfully compiled and linked Rot on cygwin.




jlambert@agamemnon /c/muds/Rot/src
$ ls rot*
rot.exe



There it is.


On to the script.



jlambert@agamemnon /c/muds/Rot/src
$ cd ../area

jlambert@agamemnon /c/muds/Rot/area
$ ls star*
startup

jlambert@agamemnon /c/muds/Rot/area
$ cat startup
#!/bin/csh

set areapath = /Rot/area
set port = 4000
set wwwport = 4001

cd $areapath

# Set limits.
if ( -e shutdown.txt ) rm -f shutdown.txt

while ( 1 )
# If you want to have logs in a different directory,
# change the 'set logfile' line to reflect the directory name.
set index = 1000
while ( 1 )
set logfile = ../log/$index.log
if ( ! -e $logfile ) break
@ index++
end

# Copy rot binary from bin directory.
# after a compile, place the new binary in the bin directory,
# this way a reboot will install the new binary, instead of
# of having to shut down.
rm -f ./rot
cp ../bin/rot .
# Run rot.
./rot $port $wwwport >&! $logfile

# Restart, giving old connections a chance to die.
if ( -e shutdown.txt ) then
rm -f shutdown.txt
exit 0
endif
sleep 15
end



Note the very first line of the script. It contains the sharp-bang (or bangline) which is used to to indicate what program or shell will be used to run the this script. This script was written for csh or the c-shell.


Looks like this mud will run by default on ports 4000 and 4001 (webserver?).

There are a couple of potential problems here, so we'll edit it.



jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

First..

set areapath = /Rot/area

That's not my absolute path to the area directory, let's change that to mine.

set areapath = /c/muds/Rot/area

Second...
rm -f ./rot
cp ../bin/rot .
# Run rot.
./rot $port $wwwport >&! $logfile

Cygwin executables use the .exe extension so this needs to be.
rm -f ./rot.exe
cp ../bin/rot.exe .
# Run rot.exe
./rot.exe $port $wwwport >&! $logfile


How odd. Looks like the script assumes the Rot executable is in the bin directory.
It ain't friggin' there. I guess we'll copy it there manually for now.



jlambert@agamemnon /c/muds/Rot/area
$ cp ../src/rot.exe ../bin


Note: The script above apparently can be run from anywhere as the statement, cd $areapath, guarantees all the relative paths will be from the area directory.


So let's run it.



jlambert@agamemnon /c/muds/Rot/area
$ ./startup &
[1] 3736


The & parameter causes the script to run in the background. If you didn't use it, your console session would be locked up until the mud shutdown.



jlambert@agamemnon /c/muds/Rot/area
$ ps
PID PPID PGID WINPID TTY UID STIME COMMAND
3760 1 3760 3760 con 1004 13:03:49 /usr/bin/bash
3736 3760 3736 2908 con 1004 14:58:48 /usr/bin/tcsh
2856 3736 3736 2084 con 1004 14:58:49 /c/muds/Rot/area/rot
2152 3760 2152 1484 con 1004 14:58:52 /usr/bin/ps



Looks like it's running.



jlambert@agamemnon /c/muds/Rot/area
$ telnet localhost 4000
Trying 127.0.0.1...
Connected to agamemnon.
Escape character is '^]'.


This is Greeting #3

Original DikuMUD by Hans Staerfeldt, Katja Nyboe,
Tom Madsen, Michael Seifert, and Sebastian Hammer
Based on MERC 2.1 code by Hatchet, Furey, and Kahn
ROM 2.4 copyright (c) 1993-1995 Russ Taylor
ROT 1.4 copyright (c) 1996-1997 Russ Walsh

What name do you wish to use? Tyche
....etc



I went ahead and created a character and quit.

So how do I make myself a god? Shrug no friggin' documentation at all.
Well knowing a little about ROM I expect I'll have to edit the player file.



jlambert@agamemnon /c/muds/Rot/area
$ cd ../player

jlambert@agamemnon /c/muds/rot/player
$ ls
Tyche

jlambert@agamemnon /c/muds/rot/player
$ nano Tyche

#PLAYER
Name Tyche~
Id 1070395428
LogO 1070395520
Vers 5
Prom <%hhp %mm %vmv> ~
Race human~
Sex 1
Clas mage~
Levl 110 <--- changed from 1 to 110
Tru 60 <--- added this line
Plyd 92
Notb 0 0 0 0 0 0
...etc


Let's make the changes above, save, telnet back in and try a few commands.



What name do you wish to use? Tyche
Password:
Welcome Immortal!

<100hp 100m 100mv> who
Visible Immortals:
[IMP Human Mag] Tyche the Novice of Magic




Looks like I'm an IMP.




<100hp 100m 100mv> goto Hassan
The Temple Of Thoth
You are in the southern end of the temple hall in the Temple of Thoth.
The temple has been constructed from giant marble blocks, eternal in
appearance, and most of the walls are covered by ancient wall paintings
picturing gods, giants and peasants.
A small doorway leads to the west.
Large steps lead down through the grand temple gate, descending the huge
mound upon which the temple is built and ends on the temple square below.
Equally large steps lead UP through a small door into the ENTRANCE to MUD
SCHOOL. (type 'up' to go to MUD SCHOOL.) A small plaque is on this wall.
[.......L....] Hassan is here, waiting to dispense some justice.

<100hp 100m 100mv> slay h
You slay him in cold blood!
Hassan's heart is torn from his chest.




Oooo looks like I move and fight like I have super ninja mojo powers too.

I can't wait to do that to my first player!. :-P



Now let's check out the web page. Let's bring up IE and use the

URL http://127.0.0.1:4001


Hmmm something happened. I got kicked off and the mud apparently crashed and burned.




jlambert@agamemnon /c/muds/rot/log
$ ps
PID PPID PGID WINPID TTY UID STIME COMMAND
3760 1 3760 3760 con 1004 13:03:49 /usr/bin/bash
3736 3760 3736 2908 con 1004 14:58:48 /usr/bin/tcsh
3188 3736 3736 2384 con 1004 16:22:09 /c/muds/Rot/area/rot
4088 3760 4088 1400 con 1004 16:25:14 /usr/bin/ps


But it looks like the script was able to restart it as you see above.

So what happened? Let's check the log!



jlambert@agamemnon /c/muds/rot/log
$ cd ../log

jlambert@agamemnon /c/muds/rot/log
$ ls
1000.log 1001.log

jlambert@agamemnon /c/muds/rot/log
$ tail 1000.log
Tue Dec 2 15:05:20 2003 :: Tyche has quit.
Tue Dec 2 16:10:58 2003 :: Sock.sinaddr: 127.0.0.1
Tue Dec 2 16:11:01 2003 :: Loading Tyche.
Tue Dec 2 16:11:03 2003 :: Tyche@localhost has connected.
Tue Dec 2 16:14:19 2003 :: Tyche has quit.
Tue Dec 2 16:17:25 2003 :: Sock.sinaddr: 127.0.0.1
Tue Dec 2 16:17:27 2003 :: Loading Tyche.
Tue Dec 2 16:17:30 2003 :: Tyche@localhost has connected.
Tue Dec 2 16:21:48 2003 :: [*****] BUG: WWW-Who: fopen
/home/WWW/cgi-bin/output/rot.who: No such file or directory



Apparently the web interface crashes the mud when it can't find a file. That's real slick.


Let's look a the new log our script started.



jlambert@agamemnon /c/muds/rot/log
$ tail 1001.log
Tue Dec 2 16:22:09 2003 :: reading social.are
Tue Dec 2 16:22:09 2003 :: Fixing exits.
Tue Dec 2 16:22:09 2003 :: Area Update.
Tue Dec 2 16:22:09 2003 :: Loading Moveable Exits.
Tue Dec 2 16:22:09 2003 :: Loading Notes.
Tue Dec 2 16:22:09 2003 :: Loading Bans.
Tue Dec 2 16:22:09 2003 :: Loading Wizlist.
Tue Dec 2 16:22:09 2003 :: Loading Clanlists.
Tue Dec 2 16:22:09 2003 :: Loading Songs.
Tue Dec 2 16:22:09 2003 :: ROT is ready to rock on ports 4000 and 4001.



Apparently Rot is NOT ready to rock on port 4001!


How to fix that? That's best left as an exercise for you, the Rot monkey.


HTH


This is a annotated log of me intalling Rot under Cygwin. I had never seen Rot before. But I will be going under the assumption that a Diku is Diku no matter how many times they rename it. You've seen one, you've seen them all.

Now what packages did I need beyond the basic cygwin install.

This command lists all the installed packages.

jlambert@agamemnon /c/muds/Rot/src
$ cygcheck -c

Cygwin Package Information
Package                 Version            Status
binutils                20040312-1         OK
crypt                   1.1-1              OK
gcc                     3.3.1-3            OK
make                    3.80-1             OK
nano                    1.2.2-1            OK
tcsh                    6.12.00-7          OK

The above was editted down to the ones you need that I don't believe are installed by default but have to be selected by running the setup program again. To check for each package you can also do cygcheck -c packagename

BTW the Pico editor comes with Pine mail program. Nano has more features though. There are also Vim, Xemacs, and a bunch of other editors. DO NOT use a Windows editor to edit your source code or makefiles unless it preserves Unix style line endings and in the case of makefiles tab characters. Ultraedit, Multiedit and Textpad are Windows editors that can read and write unix text files without munging them up. Don't use Windows Notepad on anything, not even files on windows. If you really must Wordpad will get you through most files without messing them up.

Onward

First let's unpack the distribution somewhere.

jlambert@agamemnon /c/muds
$ ls Rot*
Rot1.4.tar.gz

jlambert@agamemnon /c/muds
$ gunzip Rot1.4.tar.gz

jlambert@agamemnon /c/muds
$ tar xf Rot1.4.tar

Note: If you use Winzip there are some empty directories that won't be created.

(i.e. bin, log, player, gods)

Let's find the install doc. Haha. None at all. Just the old Merc files.

I wasn't really planning on reading the instructions anyway. Good thing there ain't any. :-P

Let's find a configure or makefile somewhere. There's a makefile in the src directory.

Let's run make then.

jlambert@agamemnon /c/muds
$ cd Rot/src

jlambert@agamemnon /c/muds/Rot/src
$ make
gcc -c -Wall -O -g  act_comm.c
gcc -c -Wall -O -g  act_enter.c
gcc -c -Wall -O -g  act_info.c
act_info.c: In function `do_look':
act_info.c:1373: warning: suggest explicit braces to avoid ambiguous `else'
act_info.c:1382: warning: suggest explicit braces to avoid ambiguous `else'
act_info.c: In function `do_password':
act_info.c:3610: warning: implicit declaration of function `crypt'
act_info.c:3610: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
act_info.c:3627: warning: assignment makes pointer from integer without a cast
gcc -c -Wall -O -g  act_move.c
gcc -c -Wall -O -g  act_obj.c
act_obj.c: In function `do_put':
act_obj.c:756: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:801: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:844: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:886: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c: In function `get_cost':
act_obj.c:3322: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g  act_wiz.c
gcc -c -Wall -O -g  alias.c
gcc -c -Wall -O -g  ban.c
gcc -c -Wall -O -g  clans.c
gcc -c -Wall -O -g  comm.c
comm.c: In function `main':
comm.c:442: warning: implicit declaration of function `close'
comm.c: In function `read_from_descriptor':
comm.c:1399: warning: implicit declaration of function `read'
comm.c: In function `write_to_descriptor':
comm.c:1867: warning: implicit declaration of function `write'
comm.c: In function `nanny':
comm.c:2010: warning: implicit declaration of function `crypt'
comm.c:2010: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
comm.c:2172: warning: assignment makes pointer from integer without a cast
comm.c:2195: warning: passing arg 1 of `strcmp' makes pointer from integer without a cast
gcc -c -Wall -O -g  const.c
gcc -c -Wall -O -g  curse.c
gcc -c -Wall -O -g  db.c
db.c:60: error: conflicting types for `random'
/usr/include/stdlib.h:163: error: previous declaration of `random'
db.c:61: error: conflicting types for `srandom'
/usr/include/stdlib.h:164: error: previous declaration of `srandom'
db.c: In function `do_dump':
db.c:2982: warning: long int format, unsigned int arg (arg 4)
db.c:2998: warning: long int format, unsigned int arg (arg 4)
db.c:2998: warning: long int format, unsigned int arg (arg 6)
db.c:3006: warning: long int format, unsigned int arg (arg 4)
db.c:3006: warning: long int format, unsigned int arg (arg 6)
db.c:3016: warning: long int format, unsigned int arg (arg 4)
db.c:3016: warning: long int format, unsigned int arg (arg 6)
db.c:3028: warning: long int format, unsigned int arg (arg 4)
db.c:3043: warning: long int format, unsigned int arg (arg 4)
db.c:3043: warning: long int format, unsigned int arg (arg 6)
db.c:3051: warning: long int format, unsigned int arg (arg 4)
db.c:3051: warning: long int format, unsigned int arg (arg 6)
db.c:3055: warning: long int format, unsigned int arg (arg 4)
db.c:3059: warning: long int format, unsigned int arg (arg 4)
make: *** [db.o] Error 1

The warnings above may cause problems later on. We'll just ignore them for now and look at the errors.

db.c:60: error: conflicting types for `random'

/usr/include/stdlib.h:163: error: previous declaration of `random'

db.c:61: error: conflicting types for `srandom'

/usr/include/stdlib.h:164: error: previous declaration of `srandom'

Let's look at these lines 60-61 in db.c

jlambert@agamemnon /c/muds/Rot/src
$ nano +60 db.c

#if !defined(OLD_RAND)
long random();                 <--- line 60
void srandom(unsigned int);    <--- line 61
int getpid();
time_t time(time_t *tloc);
#endif

Poor programming practices. Don't prototype system functions. This code will cause errors on many other unixes too.

#ifndef __CYGWIN__   <--- added
#if !defined(OLD_RAND)
long random();                 
void srandom(unsigned int);
int getpid();
time_t time(time_t *tloc);
#endif
#endif  <--- added

This effectively makes this code invisible for our CYGWIN version, while not affecting our compiling on other machines. __CYGWIN__ is a macro automatically defined by our gcc configuration when we our compiling under cygwin.

Aside: One thing to check. Issue this command in your cygwin shell.

jlambert@agamemnon /c/downloads/muds
$ set | grep unix
MAKE_MODE=unix

You should get the above output. I will assume you did.

Anyway let's save the makefile (CTL-X in nano) and try make again.

jlambert@agamemnon /c/muds/Rot/src
$ make
gcc -c -Wall -O -g  db.c
db.c: In function `do_dump':
db.c:2984: warning: long int format, unsigned int arg (arg 4)
db.c:3000: warning: long int format, unsigned int arg (arg 4)
db.c:3000: warning: long int format, unsigned int arg (arg 6)
db.c:3008: warning: long int format, unsigned int arg (arg 4)
db.c:3008: warning: long int format, unsigned int arg (arg 6)
db.c:3018: warning: long int format, unsigned int arg (arg 4)
db.c:3018: warning: long int format, unsigned int arg (arg 6)
db.c:3030: warning: long int format, unsigned int arg (arg 4)
db.c:3045: warning: long int format, unsigned int arg (arg 4)
db.c:3045: warning: long int format, unsigned int arg (arg 6)
db.c:3053: warning: long int format, unsigned int arg (arg 4)
db.c:3053: warning: long int format, unsigned int arg (arg 6)
db.c:3057: warning: long int format, unsigned int arg (arg 4)
db.c:3061: warning: long int format, unsigned int arg (arg 4)
db.c: In function `init_mm':
db.c:3214: warning: implicit declaration of function `getpid'
gcc -c -Wall -O -g  db2.c
gcc -c -Wall -O -g  effects.c
gcc -c -Wall -O -g  fight.c
fight.c: In function `one_hit':
fight.c:722: warning: suggest explicit braces to avoid ambiguous `else'
fight.c:728: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `one_hit_mock':
fight.c:1071: warning: suggest explicit braces to avoid ambiguous `else'
fight.c:1077: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `damage':
fight.c:1375: warning: suggest explicit braces to avoid ambiguous `else'
fight.c: In function `damage_old':
fight.c:1794: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g  finger.c
gcc -c -Wall -O -g  flags.c
gcc -c -Wall -O -g  forget.c
gcc -c -Wall -O -g  handler.c
handler.c: In function `reset_char':
handler.c:632: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `get_max_train':
handler.c:828: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `unequip_char':
handler.c:1782: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g  healer.c
gcc -c -Wall -O -g  interp.c
gcc -c -Wall -O -g  note.c
gcc -c -Wall -O -g  lookup.c
gcc -c -Wall -O -g  magic.c
magic.c: In function `obj_cast_spell':
magic.c:812: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g  magic2.c
gcc -c -Wall -O -g  music.c
gcc -c -Wall -O -g  recycle.c
gcc -c -Wall -O -g  repent.c
gcc -c -Wall -O -g  save.c
gcc -c -Wall -O -g  scan.c
gcc -c -Wall -O -g  sign.c
gcc -c -Wall -O -g  skills.c
gcc -c -Wall -O -g  special.c
gcc -c -Wall -O -g  tables.c
gcc -c -Wall -O -g  update.c
gcc -c -Wall -O -g  wizlist.c
rm -f rot
gcc -O -g -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o act_wiz.o
 alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o fight.o finger.o 
flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.o magic2.o 
music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o tables.o update.o 
wizlist.o
act_info.o(.text+0xa59c): In function `do_password':
/c/muds/Rot/src/act_info.c:3610: undefined reference to `_crypt'
act_info.o(.text+0xa633):/c/muds/Rot/src/act_info.c:3627: undefined reference to `_crypt'
comm.o(.text+0x385e): In function `nanny':
/c/muds/Rot/src/comm.c:2010: undefined reference to `_crypt'
comm.o(.text+0x3e85):/c/muds/Rot/src/comm.c:2172: undefined reference to `_crypt'
comm.o(.text+0x3f19):/c/muds/Rot/src/comm.c:2195: undefined reference to `_crypt'
collect2: ld returned 1 exit status
make: *** [rot] Error 1

We got much further. Everything has compiled successfully. However we are unable to link together our object modules into an executable. It appears the linker cannot find a system function know as crypt. (The leading underscore can be ignored as it's C's way of mangling function names).

Many systems don't come with the crypt library installed and/or don't include it in the linker's default list of libraries.

jlambert@agamemnon /c/muds/Rot/src
$ find /lib -name libcrypt.a
/lib/libcrypt.a

Yep I have it. So we need to update the Makefile to include it manually.

jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

L_FLAGS =  $(PROF) -lcrypt  <--- added crypt library

The -l flag will tell the linker to include the library when linking. Note the naming convention differences from how the file is named and how one includes it.

Let's see what happens:

jlambert@agamemnon /c/muds/Rot/src
$ make
rm -f rot
gcc -O -g -lcrypt -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o
act_wiz.o alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o fight.o 
finger.o flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.o 
magic2.o music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o tables.o 
update.o wizlist.o
act_info.o(.text+0xa59c): In function `do_password':
/c/muds/Rot/src/act_info.c:3610: undefined reference to `_crypt'
act_info.o(.text+0xa633):/c/muds/Rot/src/act_info.c:3627: undefined reference to `_crypt'
comm.o(.text+0x385e): In function `nanny':
/c/muds/Rot/src/comm.c:2010: undefined reference to `_crypt'
comm.o(.text+0x3e85):/c/muds/Rot/src/comm.c:2172: undefined reference to `_crypt'
comm.o(.text+0x3f19):/c/muds/Rot/src/comm.c:2195: undefined reference to `_crypt'
collect2: ld returned 1 exit status
make: *** [rot] Error 1

What?! Still can't find it. Why? The linker searches libraries from left to right and only for those functions called by an object file. So we need to place our -lcrypt after the object files (.o files) otherwise it'll never be searched for anything. The is probably where your typical newbie gives up and says cygwin just doesn't plain work with crypt.

Let's edit the makefile again...

jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

L_FLAGS =  $(PROF)   <-- put this back the way it was
... and down below
rot: $(ROT_FILES)
        rm -f rot
        $(CC) $(L_FLAGS) -o rot $(ROT_FILES) -lcrypt  <-- add our library here

Now save and try again...

jlambert@agamemnon /c/muds/Rot/src
$ make
rm -f rot
gcc -O -g  -o rot act_comm.o act_enter.o act_info.o act_move.o act_obj.o act_wiz.o 
alias.o ban.o clans.o comm.o const.o curse.o db.o db2.o effects.o fight.o finger.o 
flags.o forget.o handler.o healer.o interp.o note.o lookup.o magic.o magic2.o 
music.o recycle.o repent.o save.o scan.o sign.o skills.o special.o tables.o
update.o wizlist.o -lcrypt

Voila! We've successfully compiled and linked Rot on cygwin.

jlambert@agamemnon /c/muds/Rot/src
$ ls rot*
rot.exe

There it is.

On to the script.

jlambert@agamemnon /c/muds/Rot/src
$ cd ../area

jlambert@agamemnon /c/muds/Rot/area
$ ls star*
startup

jlambert@agamemnon /c/muds/Rot/area
$ cat startup
#!/bin/csh

set areapath = /Rot/area
set port = 4000
set wwwport = 4001

cd $areapath

# Set limits.
if ( -e shutdown.txt ) rm -f shutdown.txt

while ( 1 )
    # If you want to have logs in a different directory,
    #   change the 'set logfile' line to reflect the directory name.
    set index = 1000
    while ( 1 )
        set logfile = ../log/$index.log
        if ( ! -e $logfile ) break
        @ index++
    end

    # Copy rot binary from bin directory.
    # after a compile, place the new binary in the bin directory,
    # this way a reboot will install the new binary, instead of
    # of having to shut down.
    rm -f ./rot
    cp ../bin/rot .
    # Run rot.
    ./rot $port $wwwport >&! $logfile

    # Restart, giving old connections a chance to die.
    if ( -e shutdown.txt ) then
        rm -f shutdown.txt
        exit 0
    endif
    sleep 15
end

Note the very first line of the script. It contains the sharp-bang (or bangline) which is used to to indicate what program or shell will be used to run the this script. This script was written for csh or the c-shell.

Looks like this mud will run by default on ports 4000 and 4001 (webserver?).

There are a couple of potential problems here, so we'll edit it.

jlambert@agamemnon /c/muds/Rot/src
$ nano Makefile

First..

set areapath = /Rot/area

That's not my absolute path to the area directory, let's change that to mine.

set areapath = /c/muds/Rot/area

Second...
    rm -f ./rot
    cp ../bin/rot .
    # Run rot.
    ./rot $port $wwwport >&! $logfile
    
Cygwin executables use the .exe extension so this needs to be.
    rm -f ./rot.exe
    cp ../bin/rot.exe .
    # Run rot.exe
    ./rot.exe $port $wwwport >&! $logfile

How odd. Looks like the script assumes the Rot executable is in the bin directory. It ain't friggin' there. I guess we'll copy it there manually for now.

jlambert@agamemnon /c/muds/Rot/area
$ cp ../src/rot.exe ../bin

Note: The script above apparently can be run from anywhere as the statement, cd $areapath, guarantees all the relative paths will be from the area directory.

So let's run it.

jlambert@agamemnon /c/muds/Rot/area
$ ./startup &
[1] 3736

The & parameter causes the script to run in the background. If you didn't use it, your console session would be locked up until the mud shutdown.

jlambert@agamemnon /c/muds/Rot/area
$ ps
      PID    PPID    PGID     WINPID  TTY  UID    STIME COMMAND
     3760       1    3760       3760  con 1004 13:03:49 /usr/bin/bash
     3736    3760    3736       2908  con 1004 14:58:48 /usr/bin/tcsh
     2856    3736    3736       2084  con 1004 14:58:49 /c/muds/Rot/area/rot
     2152    3760    2152       1484  con 1004 14:58:52 /usr/bin/ps

Looks like it's running.

jlambert@agamemnon /c/muds/Rot/area
$ telnet localhost 4000
Trying 127.0.0.1...
Connected to agamemnon.
Escape character is '^]'.


         This is Greeting #3

                Original DikuMUD by Hans Staerfeldt, Katja Nyboe,
                Tom Madsen, Michael Seifert, and Sebastian Hammer
                Based on MERC 2.1 code by Hatchet, Furey, and Kahn
                ROM 2.4 copyright (c) 1993-1995 Russ Taylor
                ROT 1.4 copyright (c) 1996-1997 Russ Walsh

What name do you wish to use? Tyche
....etc

I went ahead and created a character and quit.

So how do I make myself a god? Shrug no friggin' documentation at all. Well knowing a little about ROM I expect I'll have to edit the player file.

jlambert@agamemnon /c/muds/Rot/area
$ cd ../player

jlambert@agamemnon /c/muds/rot/player
$ ls
Tyche

jlambert@agamemnon /c/muds/rot/player
$ nano Tyche

#PLAYER
Name Tyche~
Id   1070395428
LogO 1070395520
Vers 5
Prom <%hhp %mm %vmv> ~
Race human~
Sex  1
Clas mage~
Levl 110  <--- changed from 1 to 110
Tru  60   <--- added this line
Plyd 92
Notb  0 0 0 0 0 0
...etc

Let's make the changes above, save, telnet back in and try a few commands.

What name do you wish to use? Tyche
Password:
Welcome Immortal!

<100hp 100m 100mv> who
Visible Immortals:
[IMP Human  Mag] Tyche the Novice of Magic

Looks like I'm an IMP.

<100hp 100m 100mv> goto Hassan
The Temple Of Thoth
  You are in the southern end of the temple hall in the Temple of Thoth.
The temple has been constructed from giant marble blocks, eternal in
appearance, and most of the walls are covered by ancient wall paintings
picturing gods, giants and peasants.
   A small doorway leads to the west.
   Large steps lead down through the grand temple gate, descending the huge
mound upon which the temple is built and ends on the temple square below.
   Equally large steps lead UP through a small door into the ENTRANCE to MUD
SCHOOL.  (type 'up' to go to MUD SCHOOL.)  A small plaque is on this wall.
[.......L....] Hassan is here, waiting to dispense some justice.

<100hp 100m 100mv> slay h
You slay him in cold blood!
Hassan's heart is torn from his chest.

Oooo looks like I move and fight like I have super ninja mojo powers too.

I can't wait to do that to my first player!. :-P

Now let's check out the web page. Let's bring up IE and use the

URL http://127.0.0.1:4001

Hmmm something happened. I got kicked off and the mud apparently crashed and burned.

jlambert@agamemnon /c/muds/rot/log
$ ps
      PID    PPID    PGID     WINPID  TTY  UID    STIME COMMAND
     3760       1    3760       3760  con 1004 13:03:49 /usr/bin/bash
     3736    3760    3736       2908  con 1004 14:58:48 /usr/bin/tcsh
     3188    3736    3736       2384  con 1004 16:22:09 /c/muds/Rot/area/rot
     4088    3760    4088       1400  con 1004 16:25:14 /usr/bin/ps

But it looks like the script was able to restart it as you see above.

So what happened? Let's check the log!

jlambert@agamemnon /c/muds/rot/log
$ cd ../log

jlambert@agamemnon /c/muds/rot/log
$ ls
1000.log  1001.log

jlambert@agamemnon /c/muds/rot/log
$ tail 1000.log
Tue Dec  2 15:05:20 2003 :: Tyche has quit.
Tue Dec  2 16:10:58 2003 :: Sock.sinaddr:  127.0.0.1
Tue Dec  2 16:11:01 2003 :: Loading Tyche.
Tue Dec  2 16:11:03 2003 :: Tyche@localhost has connected.
Tue Dec  2 16:14:19 2003 :: Tyche has quit.
Tue Dec  2 16:17:25 2003 :: Sock.sinaddr:  127.0.0.1
Tue Dec  2 16:17:27 2003 :: Loading Tyche.
Tue Dec  2 16:17:30 2003 :: Tyche@localhost has connected.
Tue Dec  2 16:21:48 2003 :: [*****] BUG: WWW-Who: fopen
/home/WWW/cgi-bin/output/rot.who: No such file or directory

Apparently the web interface crashes the mud when it can't find a file. That's real slick.

Let's look a the new log our script started.

jlambert@agamemnon /c/muds/rot/log
$ tail 1001.log
Tue Dec  2 16:22:09 2003 :: reading social.are
Tue Dec  2 16:22:09 2003 :: Fixing exits.
Tue Dec  2 16:22:09 2003 :: Area Update.
Tue Dec  2 16:22:09 2003 :: Loading Moveable Exits.
Tue Dec  2 16:22:09 2003 :: Loading Notes.
Tue Dec  2 16:22:09 2003 :: Loading Bans.
Tue Dec  2 16:22:09 2003 :: Loading Wizlist.
Tue Dec  2 16:22:09 2003 :: Loading Clanlists.
Tue Dec  2 16:22:09 2003 :: Loading Songs.
Tue Dec  2 16:22:09 2003 :: ROT is ready to rock on ports 4000 and 4001.

Apparently Rot is NOT ready to rock on port 4001!

How to fix that? That's best left as an exercise for you, the Rot monkey.

HTH


TheSourcery | RecentChanges | Preferences | Index | RSS
Edit text of this page | View other revisions
Last edited June 11, 2005 2:01 am by JonLambert (diff)
Search:
All material on this Wiki is the property of the contributing authors.
©2004-2006 by the contributing authors.
Ideas, requests, problems regarding this site? Send feedback.