15 Nov, 2009, Tumeski wrote in the 1st comment:
Votes: 0
Hello everyone,

I quess this has been asked a few times, but I just couldnt find a answer that pleases me so I start a new topic about it. Okay the case is that I merged the account management system to the fresh QuickMud files. Okay it compiles fine and seems to work fine, okay, I connect to it and start creating account, I finish writing the confirm password and at that same moment it should create the .dat file for the account. Doesn't happen and I get a segmention fault. So, where do I start or does someone happen to have working code for it?

Or the best of all if someone could slip the code in a fresh QuickMud files.

Thanks,
Tumeski
15 Nov, 2009, tphegley wrote in the 2nd comment:
Votes: 0
Run it through GDB.

In area folder (Not sure if this works with ROM) do gdb ../src/rom and then run. This should run it in gdb. log in normally and go through creation process and see where it faults. I'm sure someone will link Nick Gammons' guide soon. But check out his site and look through the smaug section and it'll have the gdb info.
15 Nov, 2009, Runter wrote in the 3rd comment:
Votes: 0
Yes, that should work with rom.
15 Nov, 2009, David Haley wrote in the 4th comment:
Votes: 0
Here is Nick's guide to gdb: http://mushclient.com/gdb
15 Nov, 2009, Mudder wrote in the 5th comment:
Votes: 0
That guide was pretty helpful… Maybe I should try and download gdb myself. :grinning:
15 Nov, 2009, Runter wrote in the 6th comment:
Votes: 0
Mudder said:
That guide was pretty helpful… Maybe I should try and download gdb myself. :grinning:


Yeah. At some point you want to learn to some debugger if you're going to be working in C/C++. It can be incredibly difficult to debug without some type of tool in larger applications.
15 Nov, 2009, Tumeski wrote in the 7th comment:
Votes: 0
Thanks everyone for your help. Im using GDB now. Feels good, its like any debugger in a IDE. Anyway… I've been crashin on this. I can't find anyone using a similiar account system other than EOTC, but they've completely remade it so its hard to slip it in.

This is what GDB gets
Core was generated by `../src/rom 9000'.
Program terminated with signal 11, Segmentation fault.
[New process 5345]
#0 0x08049926 in show_options (dsock=0xb7c2babc) at account.c:264
264 if (help_menu_1[0] == '.')


And this is the problematic void…

void show_options(DESCRIPTOR_DATA *dsock)
{
char buf[MAX_STRING_LENGTH];
extern char *help_menu_1;

send_to_desc("\x1B;
extern char *help_menu_1;

send_to_desc("\x1B[H\x1B[J",dsock);
if (help_menu_1[0] == '.')
send_to_desc (help_menu_1 + 1, dsock);
else
send_to_desc (help_menu_1, dsock);
sprintf(buf, "\n\rWelcome %s, whats your choice today.", dsock->account->owner);
send_to_desc(buf, dsock);
}
[/code]

So basically thats help_menu_1 as a table or whatever its called in english and a check if its empty?
15 Nov, 2009, kiasyn wrote in the 8th comment:
Votes: 0
help_menu_1 is probably null
16 Nov, 2009, Mudder wrote in the 9th comment:
Votes: 0
What is this account management system?
16 Nov, 2009, Tumeski wrote in the 10th comment:
Votes: 0
Mudder said:
What is this account management system?


This is an account management system. Basically when you first connect you create an account. Now you create a character to that account. You logout and come back to your account and choose your character to login. Get it?

Im loosing my mind with this stuff… EOTC is the only one that I found to share code that are using account system… Check these files out, it looks good and all, but its a way too much of changes to just change without any guidance… Any ideas anyone?

So heres EOTC version of account.c

http://www.mudbytes.net/index.php?a=past...

And this is the regular account.c

http://www.mudbytes.net/index.php?a=past...

Edit: moved large code chunks to pastebin (kiasyn)
16 Nov, 2009, JohnnyStarr wrote in the 11th comment:
Votes: 0
extern char *help_menu_1;


Where is help_menu_1 defined? You can avoid the crash with a conditional statement perhaps, but
this won't fix the fact that it is apparently a null pointer.
16 Nov, 2009, Tumeski wrote in the 12th comment:
Votes: 0
in db.c file

theres at line 92

char *help_menu_1;


and on line 651

help_menu_1 = pHelp->text;


this is the void for help.
/*
* Snarf a help section.
*/
void load_helps (FILE * fp, char *fname)
{
HELP_DATA *pHelp;
int level;
char *keyword;

for (;;)
{
HELP_AREA *had;

level = fread_number (fp);
keyword = fread_string (fp);

if (keyword[0] == '$')
break;

if (!had_list)
{
had = new_had ();
had->filename = str_dup (fname);
had->area = current_area;
if (current_area)
current_area->helps = had;
had_list = had;
}
else if (str_cmp (fname, had_list->filename))
{
had = new_had ();
had->filename = str_dup (fname);
had->area = current_area;
if (current_area)
current_area->helps = had;
had->next = had_list;
had_list = had;
}
else
had = had_list;

pHelp = new_help ();
pHelp->level = level;
pHelp->keyword = keyword;
pHelp->text = fread_string (fp);

if (!str_cmp (pHelp->keyword, "greeting"))
help_greeting = pHelp->text;

if (!str_cmp (pHelp->keyword, "menu_1"))
help_menu_1 = pHelp->text;

if (help_first == NULL)
help_first = pHelp;
if (help_last != NULL)
help_last->next = pHelp;

help_last = pHelp;
pHelp->next = NULL;

if (!had->first)
had->first = pHelp;
if (!had->last)
had->last = pHelp;

had->last->next_area = pHelp;
had->last = pHelp;
pHelp->next_area = NULL;

top_help++;
}

return;
}
16 Nov, 2009, David Haley wrote in the 13th comment:
Votes: 0
(By the way, you should use code, not quote, for posting code.)

Here's the issue:
if (!str_cmp (pHelp->keyword, "menu_1"))
help_menu_1 = pHelp->text;


help_menu_1 is set when the help file loader finds a help file with the keyword menu_1. So, you need to make sure that you indeed have a help entry with that keyword somewhere.
16 Nov, 2009, Tumeski wrote in the 14th comment:
Votes: 0
Thanks! That fixed it! I added the MENU_1 to rom.are and now thats working. Still getting a crash tough when logging out…

Program terminated with signal 11, Segmentation fault.
[New process 28418]
#0 0xb7dcfabd in fclose () from /lib/libc.so.6


:stare:
16 Nov, 2009, David Haley wrote in the 15th comment:
Votes: 0
It's possible that you're closing a file twice somewhere, although it's hard to tell from just that. What's the rest of the backtrace say?
16 Nov, 2009, Tumeski wrote in the 16th comment:
Votes: 0
it looks like this

#0  0xb7df5abd in fclose () from /lib/libc.so.6
#1 0x080c7744 in save_char_obj (ch=0xb7c2ef94) at save.c:171
#2 0x08053c18 in do_save (ch=0xb7c2ef94, argument=0xb7c2d005 "")
at act_comm.c:1529
#3 0x080a0c57 in interpret (ch=0xb7c2ef94, argument=0xb7c2d005 "")
at interp.c:554
#4 0x0806fe7e in substitute_alias (d=0xb7c2cbe0, argument=0xb7c2d001 "save")
at alias.c:67
#5 0x08077cb4 in game_loop_unix (control=5) at comm.c:842
#6 0x0807820b in main (argc=Cannot access memory at address 0xffffffff
) at comm.c:459


and im thinking that its gotta do something with saving the player file. Cause the crash is exactly the same with save command. So it can't save the player files or something :I

This is from the account.c file
void account_new_player(ACCOUNT_DATA *account, CHAR_DATA *dMob)
{
char buf[MAX_STRING_LENGTH];

sprintf(buf, "%s%s%s %d",
account->players, (account->players[0] == '\0') ? "" : " ",
dMob->name, dMob->played/3600);
free_string(account->players);
account->players = str_dup(buf);
save_account(account);
}


Or this one…

void account_update(ACCOUNT_DATA *account, CHAR_DATA *dMob)
{
char buf[MAX_STRING_LENGTH], name[MAX_STRING_LENGTH];
char *ptr, *list;
int i = 0, j = 0;

buf[0] = '\0';
ptr = buf;
list = account->players;

/* first we error check */
if (!is_full_name(dMob->name, account->players))
{
sprintf(buf, "Account_update: %s not in %s's playerlist", dMob->name, account->owner);
bug(buf, 0);
return;
}

/* then we parse */
while (1)
{
one_argument(list + i, name);
if (!str_cmp(name, dMob->name))
{
/* scan past name */
while ((buf[i + j] = *(list+i)) != ' ')
i++;
i++;

/* scan past race */
while ((buf[i + j] = *(list+i)) != ' ')
i++;
i++;

/* parse correct time */
{
char tempbuf[MAX_STRING_LENGTH];
int count = 0;

sprintf(tempbuf, "%d",
(dMob->played + (int) (current_time - dMob->logon))/3600);
while ((buf[i + j] = tempbuf[count++]) != '\0')
j++;

/* change that to a space */
buf[i + j] = ' ';

/* skip past the old time entry */
while (*(list+i) != '\0' && *(list+i) != ' ')
i++, j–;

if (*(list + (i++)) == '\0')
{
buf[i + j - 1] = '\0';
break;
}
}
}
else // scan forward one entry
{
/* scan past name */
while ((buf[i + j] = *(list+i)) != ' ')
i++;
i++;

/* scan past race */
while ((buf[i + j] = *(list+i)) != ' ')
i++;
i++;

/* scan past hours */
while ((buf[i + j] = *(list+i)) != '\0' && *(list+i) != ' ')
i++;

/* found the end */
if (*(list + (i++)) == '\0')
break;
}
}

/* then we copy */
free_string(account->players);
account->players = str_dup(buf);

/* and finally we save */
save_account(account);
}
16 Nov, 2009, David Haley wrote in the 17th comment:
Votes: 0
Hmm, you might need to look at save_char_obj and see if the character is being closed twice somehow. That's my best guess from the information so far.

You can also try running this through valgrind if it's available on your system; usually, for things like this, valgrind can tell you exactly what is going on. To run valgrind, start up your game normally (but without the startup script), except add 'valgrind' to the front of the command.

e.g.,
cd ../area
valgrind ../src/smaug

I'm not too familiar with QuickMud/ROM so I don't know the exact steps for them but the above is what you'd do for SMAUG.
16 Nov, 2009, Xrakisis wrote in the 18th comment:
Votes: 0
Eotc has modified Account code… Davion went through the snippit of account.c i installed and rewrote a bunch of it.
-Xrak
0.0/18