17 Jul, 2009, Guest wrote in the 1st comment:
Votes: 0
Hi,
im interested in installing the account system under rom->snippits. The Description says "I'd suggest manually patching this in and expect a few bugs. It works mostly bug free but it's lacking a few features."

Does anyone know what its 'lacking'?

-Xrakisis
17 Jul, 2009, Ssolvarain wrote in the 2nd comment:
Votes: 0
Strippers are the first thing that come to mind.
17 Jul, 2009, Guest wrote in the 3rd comment:
Votes: 0
I installed the snippit, i did a clean make, when i logged in i got a seg fault, i started it up in gdb and im getting

Program received signal SIGSEGV, Segmentation fault.
0x080c7b81 in load_char_obj (d=0x40665a20, name=0x40665e41 "xrakisis") at save.c:756
756 ch->pcdata->account = str_dup(d->account->owner);
(gdb) quit
The program is running. Exit anyway? (y or n) y
ianshirm@zeno:~/rom-test-port/area$

any idea why im getting this?
17 Jul, 2009, Guest wrote in the 4th comment:
Votes: 0
#0 0x080c7b81 in load_char_obj (d=0x40665da0, name=0x406661c1 "xrakisis") at save.c:756
#1 0x080b25c7 in nanny (d=0x40665da0, argument=0x406661c1 "xrakisis") at nanny.c:204
#2 0x080776d1 in game_loop_unix (control=8) at comm.c:847
#3 0x08077b6f in main (argc=Cannot access memory at address 0x3855833b
) at comm.c:460
17 Jul, 2009, David Haley wrote in the 5th comment:
Votes: 0
Chances are that d->account->owner isn't being initialized correctly, but I haven't looked at the snippet so I don't really know for sure.
18 Jul, 2009, Guest wrote in the 6th comment:
Votes: 0
Quote
Chances are that d->account->owner isn't being initialized correctly, but I haven't looked at the snippet so I don't really know for sure.


Im not sure how to go about fixing this…
18 Jul, 2009, Lobotomy wrote in the 7th comment:
Votes: 0
Xrakisis said:
Quote
Chances are that d->account->owner isn't being initialized correctly, but I haven't looked at the snippet so I don't really know for sure.


Im not sure how to go about fixing this…

You need to have it check for the existence of a pointed-to struct before it can safely access or otherwise check against a pointer within that struct. I.e, unless you know for sure that d->account exists, don't be trying to access d->account->owner or you're gambling against a crash occurring if d->account happens to be a null or a dangling pointer.
18 Jul, 2009, Guest wrote in the 8th comment:
Votes: 0
I downloaded dystopia 2.0, it has the original account system. I ported over a bunch of the code it. I fixed a ton of problems that came from missing code in the snippit, i added

/* save this new player */
account_new_player(d->account, d->character);
save_char_obj(d->character);
p/code]
under..
[code]
case CON_PICK_WEAPON:
[/code]
above
[code]
do_function (ch, &do_help, "motd");
d->connected = CON_READ_MOTD;
break;
[/code]
I did this because the account.dat file was showing number of players as 0 and not having my players name in the file under players.

When nanny gets to this code in the charachter creation process i get a seg fault..
[code]
Sat Jul 18 14:27:02 2009 :: Xrakisis@AC81E61C.ipt.aol.com new player.

Program received signal SIGSEGV, Segmentation fault.
0x08049ccc in account_update (account=0x0, dMob=0x0) at account.c:472
472 while ((buf[i] = *(list + j)) != ' ')
(gdb) bt
#0 0x08049ccc in account_update (account=0x0, dMob=0x0) at account.c:472
#1 0x00000000 in ?? ()
(gdb)

Thats in
+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 */
472 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);
+}
[/code]

Im not sure whats going wrong, any help would be greatly appreciated.-Xrak
18 Jul, 2009, Guest wrote in the 9th comment:
Votes: 0
The account.dat file in rom-test-port/accounts/Ianshirm is now saying
Denied            0
Level 1
Owner Ianshirm~
Password XXX
PCount 1
Players Xrakisis 0~
EOF



It was crashing at this…
/* save this new player */
account_new_player(d->account, d->character);
save_char_obj(d->character); (i commented this line out and it went through)

Now when it gets to the part where it gives me my list of charachters i get this

Program received signal SIGSEGV, Segmentation fault.
parse_player_list (list=0x4066c5d1 "") at account.c:347
347 *ptr2++ = *list++;
(gdb) bt
#0 parse_player_list (list=0x4066c5d1 "") at account.c:347
#1 0x00000000 in ?? ()
(gdb)
18 Jul, 2009, Banner wrote in the 10th comment:
Votes: 0
Check out this General guide to GDB, it will help you track down your problem.
19 Jul, 2009, Davion wrote in the 11th comment:
Votes: 0
You said you installed this snippet. If you patched it in, I think there could be some problems. I was looking over the patch and noticed a few things.

@@ -1420,9 +1422,9 @@
UMIN (ch->level, sizeof (pose_table) / sizeof (pose_table[0]) - 1);

pose = number_range (0, level);

- act (pose_table[pose].message[2 * ch->class + 0], ch, NULL, NULL,
+ act (pose_table[pose].message[2 * ch->race + 0], ch, NULL, NULL,TO_CHAR);

- act (pose_table[pose].message[2 * ch->class + 1], ch, NULL, NULL,
+ act (pose_table[pose].message[2 * ch->race + 1], ch, NULL, NULL, TO_ROOM);


* All the posing stuff.
*/
struct pose_table_type {
- char *message[2 * MAX_CLASS];
+ char *message[2 * MAX_PC_RACE];
};


as well as
diff -NaurBdw QuickMUD/src/act_move.c rom/src/act_move.c
— QuickMUD/src/act_move.c Fri Dec 1 03:48:32 2000
+++ rom/src/act_move.c Mon Apr 8 02:38:26 2002
@@ -39,15 +39,25 @@
#include "merc.h"
#include "interp.h"

-char *const dir_name[] = {
- "north", "east", "south", "west", "up", "down"
+char *const dir_name[] =
+{
+ "north", "east", "south", "west", "up", "down",
+ "northwest", "northeast", "southwest", "southeast"
};

-const sh_int rev_dir[] = {
- 2, 3, 0, 1, 5, 4
+char * const dir_rev [] =
+{
+ "the south", "the west", "the north", "the east", "below", "above",
+ "the southeast", "the southwest", "the northeast", "the northwest"
};


-const sh_int movement_loss[SECT_MAX] = {
+const sh_int rev_dir[] =
+{
+ 2, 3, 0, 1, 5, 4, 6, 7, 8, 9
+};
+
+const sh_int movement_loss[SECT_MAX] =
+{
1, 2, 2, 3, 4, 6, 4, 1, 6, 10, 6
};



None of these things have anything to do with an account system…
19 Jul, 2009, Guest wrote in the 12th comment:
Votes: 0
I didnt patch it in, i thought that only worked with completly stock codebases. I put it in line by line, and compared it with Dystopia 2.0 to get some of the things the snippit was lacking, There is more needed id guess cause its not working yet. Im stumped though, been at it for hours and hours.
-Xrakisis
19 Jul, 2009, Guest wrote in the 13th comment:
Votes: 0
Thanks Davion, for looking through the snippit to try to help me. :)
19 Jul, 2009, Guest wrote in the 14th comment:
Votes: 0
Does anyone know if my problem is with ptr2 (race) or if its list? i see list defined but i dont see anything telling list what to be…
-Xrak

Program received signal SIGSEGV, Segmentation fault.
parse_player_list (list=0x4066c5d1 "") at account.c:347
347 *ptr2++ = *list++;
(gdb) bt
#0 parse_player_list (list=0x4066c5d1 "") at account.c:347
#1 0x00000000 in ?? ()
(gdb)



struct plist *parse_player_list(char *list)
{
CHAR_DATA *dMob;
struct plist *p_list;
char tempbuf[MAX_STRING_LENGTH];
bool first = TRUE;
int total_time = 0;

if ((p_list = malloc(sizeof(*p_list))) == NULL)
{
bug("Parse_player_list: Cannot allocate memory", 0);
abort();
}
p_list->count = 0;

while (*list != '\0')
{
char name[20];
char race[20];
char *ptr1, *ptr2;
int played = 0;
bool in_game = FALSE;

name[0] = '\0'; ptr1 = name;
race[0] = '\0'; ptr2 = race;
/* get the name */
while (*list != ' ')
*ptr1++ = *list++;
*ptr1 = '\0'; list++;

/* is that player already logged on ?? */
for (dMob = char_list; dMob; dMob = dMob->next)
{
if (IS_NPC(dMob)) continue;
if (!str_cmp(dMob->name, name))
in_game = TRUE;
}

/* get the race */
while (*list != ' ')
*ptr2++ = *list++;
*ptr2 = '\0'; list++;

/* get the hours */
while (*list != ' ' && *list != '\0')
{
played *= 10;
played += *list++ - '0';
}
if (*list == ' ') list++;

p_list->count++;
sprintf(tempbuf, " [%d] %-12s %-12s %5d hour%s%s\n\r",
p_list->count, name, race, played, (played == 1) ? "" : "s",
(in_game) ? " (active)" : "");

/* add up */
total_time += played;

if (first)
{
first = FALSE;
sprintf(p_list->text, "%s", tempbuf);
}
else strcat(p_list->text, tempbuf);
}

/* should we add a line with the total time ? */
if (!first)
{
sprintf(tempbuf, "%34s %5d hour%s total\n\r", " ", total_time, (total_time == 1) ? "" : "s");
strcat(p_list->text, tempbuf);
}

return p_list;
}
19 Jul, 2009, Runter wrote in the 15th comment:
Votes: 0
# /* get the race */
# while (*list != ' ')
# *ptr2++ = *list++;
# *ptr2 = '\0'; list++;

I'm going to assume you need to change the while to

while (*list && *list != ' ')
19 Jul, 2009, Runter wrote in the 16th comment:
Votes: 0
The previous probably isn't the answer, anyways. It seems you know exactly the format of the string passed.

I'd go in GDB and use

p *list

and

p *ptr2

To see what the values actually are. (You'll probably get an invalid pointer on one or both.)
19 Jul, 2009, Guest wrote in the 17th comment:
Votes: 0
I did the first change you suggested, didnt work. How do i get to where i type either of those?
19 Jul, 2009, Runter wrote in the 18th comment:
Votes: 0
Xrakisis said:
I did the first change you suggested, didnt work. How do i get to where i type either of those?


After it dies while running in gdb it would let you example variables in the scope of where it died. p prints the value of a variable.

edit: At the same place you typed bt
19 Jul, 2009, Guest wrote in the 19th comment:
Votes: 0
Program received signal SIGSEGV, Segmentation fault.
parse_player_list (list=0x4066744c "Xrakisis 0") at account.c:321
321 list = account->players;
(gdb) p *list
$1 = 88 'X'
(gdb) p *ptr2
No symbol "ptr2" in current context.
(gdb)
19 Jul, 2009, Davion wrote in the 20th comment:
Votes: 0
Use 'print account' see what that says.
0.0/22