MudBytes
» MUDBytes Community » Codebase Specific » DikuMUD » Rom » Account Managment snip
Pages: << prev 1, 2 next >>
Account Managment snip
Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#1 Posted Jul 17, 2009, 11:30 am

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

Ssolvarain
Sorcerer






Group: Members
Posts: 322
Joined: Nov 14, 2008

Go to the bottom of the page Go to the top of the page
#2 Posted Jul 17, 2009, 2:27 pm

Strippers are the first thing that come to mind.
.........................
Builder, End of Time eotmud.com:4000
The Rodney Dangerfield of Mudding.

Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#3 Posted Jul 17, 2009, 2:52 pm

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?

Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#4 Posted Jul 17, 2009, 3:13 pm

#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

David Haley
Wizard






Group: Members
Posts: 5,728
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#5 Posted Jul 17, 2009, 3:14 pm

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.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#6 Posted Jul 17, 2009, 9:55 pm

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...

Lobotomy
Sorcerer






Group: Members
Posts: 353
Joined: Jul 18, 2008

Go to the bottom of the page Go to the top of the page
#7 Posted Jul 17, 2009, 10:15 pm

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.

Last edited Jul 17, 2009, 10:16 pm by Lobotomy
Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#8 Posted Jul 18, 2009, 4:22 pm

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

Code (text):
1
2
3
4
5
6
7
8
9
10
11
 
      /* save this new player */
      account_new_player(d->account, d->character);
      save_char_obj(d->character);
p/code]
under..
[code]
        case CON_PICK_WEAPON:
 

above
Code (text):
1
2
3
4
5
6
7
 
            do_function (ch, &do_help, "motd");
            d->connected = CON_READ_MOTD;
            break;
 

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 (text):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 
Sat Jul 18 14:27:02 2009 :: [email]Xrakisis@AC81E61C.ipt.aol.com[/email] 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);
+}
 


Im not sure whats going wrong, any help would be greatly appreciated.-Xrak

Last edited Jul 18, 2009, 4:35 pm by kiasyn
Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#9 Posted Jul 18, 2009, 5:33 pm

The account.dat file in rom-test-port/accounts/Ianshirm is now saying
Code (text):
1
2
3
4
5
6
7
8
9
Denied            0
Level             1
Owner             Ianshirm~
Password          XXX
PCount            1
Players           Xrakisis 0~
EOF



It was crashing at this...
   
Code (text):
1
2
3
4
5
/* 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

Code (text):
1
2
3
4
5
6
7
8
9
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)


Banner
Sorcerer






Group: Members
Posts: 381
Joined: Jul 14, 2006

Go to the bottom of the page Go to the top of the page
#10 Posted Jul 18, 2009, 7:52 pm

Check out this General guide to GDB, it will help you track down your problem.
.........................
sudo apt-get sandwich

Directions on a slingshot I bought(seriously):
No in the mouth. No to wind. No aim peoples.

Davion
Idle Hand




Group: Administrators
Posts: 1,188
Joined: May 14, 2006

Go to the bottom of the page Go to the top of the page
#11 Posted Jul 19, 2009, 4:14 am

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.

Code (text):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
 -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);
 


Code (text):
1
2
3
4
5
6
7
8
9
10
 
* All the posing stuff.
*/
struct pose_table_type {
- char *message[2 * MAX_CLASS];
+ char *message[2 * MAX_PC_RACE];
};
 


as well as
Code (text):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
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...
.........................
http://mudbytes.net/mudbytessignature-davion2.png

Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#12 Posted Jul 19, 2009, 11:13 am

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

Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#13 Posted Jul 19, 2009, 11:39 am

Thanks Davion, for looking through the snippit to try to help me. :)

Guest
Unregistered


Go to the bottom of the page Go to the top of the page
#14 Posted Jul 19, 2009, 11:48 am

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

Code (text):
1
2
3
4
5
6
7
8
9
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)



Code (text):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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;
}

Runter
Wizard






Group: Members
Posts: 1,074
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#15 Posted Jul 19, 2009, 12:05 pm

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

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

Code (text):
1
2
3
4
5
 
while (*list && *list != ' ')  
 


.........................
-Heath

For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
                                              Leonardo Da Vinci Yukihiro Matsumoto

Pages:<< prev 1, 2 next >>

Valid XHTML 1.1! Valid CSS!