[*****] BUG: Char_to_room: NULL

Posted by Syciec on Wed 30 Dec 2009 03:54 PM — 11 posts, 50,169 views.

#0
I run the .exe to start the server, and it's loaded. I go through the character creation process, but when it gets to the end and says "Press RETURN to continue" the MUD crashes.

Here is the output in shell:

Project is running on port 2700.
Sock.sinaddr: 127.0.0.1
[*****] BUG: Char_to_room: NULL
[*****] BUG: Syciec
[*****] BUG: Extract_char: NULL
Syciec@127.0.0.1 new player
Syciec@127.0.0.1 has lost all common sense
*** BUG *** Crash!!! Recovery attempted.

Where should I be looking in the source to fix this? I search around for char_to_room and there are instances, but I'm unsure of what to amend or why.

Here is code from VOID extract_char:

VOID extract_char( PCHAR_DATA ch, BOOL fPull )
{
PCHAR_DATA wch;
POBJ_DATA obj;
POBJ_DATA obj_next;
PROOM_INDEX_DATA oldroom,newroom;

if ( ch->in_room == NULL )
{
bug( "Extract_char: NULL.", 0 );
return;
}


And here is code from VOID char_to_room:

VOID char_to_room( PCHAR_DATA ch, PROOM_INDEX_DATA pRoomIndex )
{
if ( pRoomIndex == NULL )
{
PROOM_INDEX_DATA room;

bug( "Char_to_room: NULL.", 0 );
bug(ch->name,0);
if ((room = get_room_index(ROOM_VNUM_LIMBO)) != NULL)
char_to_room(ch,room);
return;
}



Thanks :)
USA #1
What codebase are you using?

What is the starting room?
Australia Forum Administrator #2
Were there errors during loading the areas? Did you alter the default area files, or file which lists which areas to load?
Canada #3
The function void char_to_room in the stock ROM and QuickMUD I looked at are vastly different than yours. You've not said if you've modified the code in any way.

void char_to_room   (CHAR_DATA * ch, ROOM_INDEX_DATA * pRoomIndex)
{
       OBJ_DATA *obj;

      if   (pRoomIndex == NULL)
     {
            ROOM_INDEX_DATA *room;

            bug ("Char_to_room: NULL.", 0);

            if   ((room = get_room_index (ROOM_VNUM_TEMPLE)) != NULL)
                  char_to_room (ch, room);

            return;
      }
etc, etc


It looks like your issue is your function has ROOM_VNUM_LIMBO instead of TEMPLE. New chars should never start in limbo.
#4
@Hanaisse: the code was sent to me by a friend. It's modified ROM code afaik.

@Nick: Now that you mention it, I did get a "area.lst not found" error before I got to this. I "fixed" it by creating a blank area.lst file and popping it into the area folder.

What would it need to contain to work? I'm fairly new to this.
Canada #5
Oh, well, no area.lst file is most likely the cause then.

You'll want area.lst to contain every .are file in your area folder in a simple list.

Example;
immort.are
midgaard.are
social.are
rom.are
school.are
limbo.are
help.are
$


These are probably the most important ones to load, but you can load up all your areas. Note the list must end with the $.
Australia Forum Administrator #6
You could do:


ls -1 *.are


That would put each area name into a line on its own. Then copy and paste that into your area.lst file, adding a "$" on a line on its own at the end.

That is a "one" after the "ls" not an "L".

As Hanaisse said, if you don't load any areas, there aren't any rooms in the MUD, and it doesn't have anywhere to put people.
USA #7
You could even automate it completely by doing this:

ls -1 *.are | cat > area.lst | echo $ | cat >> area.lst


That does the copying for you. (EDIT: figured out a way to add the last $, heh)
Amended on Sun 03 Jan 2010 01:05 AM by Twisol
#8
Oops it's been a while. I did amend the area.lst, but I still get the same problem. I make a new character, and as I'm about to enter the game, crash.
Australia Forum Administrator #9
Did you fix the message about no area.list file? It is possible the starting room does not exist, very probable if it crashes the moment you start. You need to find what the starting room number is (look in mud.h or rom.h or whatever it is), and then make sure that room is in one of your area files.

Failing that, use gdb and put a breakpoint on the line:


bug ("Char_to_room: NULL.", 0);


Then do a backtrace (bt) and see what room number it is trying to use.

http://www.gammon.com.au/gdb
Amended on Fri 26 Mar 2010 09:06 PM by Nick Gammon
#10
Lucky for me I have a friend who is a dabhand at this kind of thing, and he fixed it and the code is now running fine. The problem apparently was, and I quote, "there was multiple char_to_rooms".

So it was trying to spawn the person multiple times, and this was apparently causing the crash.

It's fixed now either way, but thanks for helping!